package com.imsl.test.example.stat; import com.imsl.stat.EGARCH; import com.imsl.stat.TimeSeries; import java.util.logging.Level; import java.util.logging.Logger; /** *
* Fits an EGARCH(1, 1) with an ARMA(1,1) on the mean. *
* ** This example fits the exponential GARCH (EGARCH) with an ARMA(1,1) * for the mean process. The data is a segment of S&P 500 returns * for a period in 1988. Forecasts 4 steps ahead from the end of the * series are generated. *
* * @see Code * @see Output */ public class EGARCHEx3 { public static void main(String args[]) { double data1[] = { 0.940543272, 2.664279727, 0.252045652, 1.221098464, 0.270575973, 0.446882726, 0.073672969, -4.450030305, 0.007699415, -0.215808015, -0.498908466, -0.696433123, 0.113159704, 1.440322251, 0.887874183, 0.5585227, -0.049267619, -0.452119841, -0.488606538, 0.087972619, 0.549032948, -1.024238871, -0.589472147, -0.507487482, -0.365744931, 0.42010331, -1.687159586, 0.212950629, 1.147614577, 0.748805609, -1.311175287, -1.574960025, 0.484204788, 0.178009897, -0.869311816, 1.062785115, 0.098566846, 0.342257263, -0.47633197 }; TimeSeries ts; ts = new TimeSeries(); ts.setSeriesValues(data1); int[] meanModel = {1, 0, 1}; EGARCH egarch = new EGARCH(ts, 1, 1, meanModel); String[] names = {"mu", "meanAlpha1", "meanBeta1", "omega", "alpha", "beta", "gamma"}; try { egarch.estimate(); double[] parameters = egarch.getParameters(); int nParameters = egarch.getNumberOfParameters(); int T = egarch.getT(); double[][][] forecasts = egarch.forecast(1, 4); System.out.println("Parameter estimates:"); for (int j = 0; j < nParameters; j++) { System.out.printf("%s: %3.4f \n", names[j], parameters[j]); } System.out.println("\n Forecasts 1-4 steps ahead from 1 snapshot origin:"); System.out.println("t \t Epsilon \t Conditional variance "); for (int j = 0; j < 4; j++) { System.out.printf("%d \t %3.4f \t%3.4f\n", T + j + 1, forecasts[0][j][0], forecasts[0][j][1]); } } catch (Exception ex) { Logger.getLogger(EGARCHEx3.class.getName()).log(Level.SEVERE, null, ex); } } }