ARMA: ISlARMAGARCH;
The ARMA property returns autoregression and moving average parameters.
Be default autoregression order and moving average order are not specified.
To execute the example, add a link to the Stat system assembly.
Sub Print(Data: Array Of Double);
Var
i: Integer;
Begin
Debug.Indent;
For i := 0 To Data.Length - 1 Do
If Double.IsNan(Data[i]) Then
Debug.WriteLine("----empty---");
Else
Debug.WriteLine(i.ToString + " " + Data[i].ToString);
End If;
End For;
Debug.Unindent;
End Sub Print;
Sub UserProc;
Var
GARCH: ISmGARCH;
W: Array[12] Of Double;
X: Array[20] Of Double;
ARMA: ISlARMAGARCH;
Inits: Array[1] Of Double;
res, i: Integer;
d: Double;
CoefficientsAR, CoefficientsMA, GARCHCoef, RegrCoef: ICoefficients;
ModelCoefficients: IGARCHCoefficients;
Begin
GARCH := New SmGARCH.Create;
// Set explained series values
w[0] := 2; w[4] := -1.9; w[8] := -0.7;
w[1] := 0.8; w[5] := Double.Nan; w[9] := Double.Nan;
w[2] := -0.3; w[6] := 3.2; w[10] := 4.3;
w[3] := -0.3; w[7] := 1.6; w[11] := 1.1;
GARCH.Explained.Value := w;
// Set explanatory series values
x[0] := Double.Nan; x[10] := 11;
x[1] := 2; x[11] := 12;
x[2] := 3; x[12] := 13;
x[3] := 4; x[13] := Double.Nan;
x[4] := 5; x[14] := 15;
x[5] := 6; x[15] := 16;
x[6] := Double.Nan; x[16] := 17;
x[7] := 8; x[17] := Double.Nan;
x[8] := 9; x[18] := 19;
x[9] := 10; x[19] := 20;
// Set sample period
GARCH.ModelPeriod.FirstPoint := 1;
GARCH.ModelPeriod.LastPoint := 12;
GARCH.Forecast.LastPoint := 19;
// Specify missing data treatment method
GARCH.MissingData.Method := MissingDataMethod.AnyValue;
// Set explanatory series
GARCH.Explanatories.Clear;
GARCH.Explanatories.Add.Value := X;
// Set initial approximation of exogenous variable
GARCH.Explanatories.Item(0).InitValue := 0.7;
ModelCoefficients := GARCH.GARCHCoefficients;
//Set initial approximation of constant
GARCH.Intercept.Mode := InterceptMode.AutoEstimate;
//Use initial values used by default
GARCH.UseDefaultInitValues := True;
// Set parameters of autoregression and moving average
GARCH.ARMA.ParseAR("2", True);
GARCH.ARMA.ParseMA("1", True);
ARMA := GARCH.ARMA;
// Determine stationarity condition
GARCH.StationarityCondition := False;
// Set maximum number of iterations for method calculation
GARCH.MaxIteration := 100;
// Set calculation accuracy
GARCH.Tolerance := 0.01;
// Set autoregression order for conditional heteroscedasticity
GARCH.ARCHOrder := 1;
// Set general autoregression order for conditional heteroscedasticity
GARCH.GARCHOrder := 1;
// Set asymmetry order
GARCH.AssymetryOrder := 2;
// Set type of GARCH model
GARCH.GARCHSpec := GARCHSpecType.GARCH;
// Execute calculation and display results
res := GARCH.Execute;
Debug.WriteLine(GARCH.Errors);
If (res = 0) Then
Debug.WriteLine("Autoregression coefficient estimations");
CoefficientsAR := ARMA.CoefficientsAR;
Debug.Indent;
d := CoefficientsAR.Estimate[0];
Debug.WriteLine("Value: " + d.ToString);
Debug.Unindent;
Debug.WriteLine("Moving average coefficient estimation");
CoefficientsMA := ARMA.CoefficientsMA;
Debug.Indent;
d := CoefficientsMA.Estimate[0];
Debug.WriteLine("Value: " + d.ToString);
Debug.Unindent;
Debug.WriteLine("Optimal value of likelihood function");
Debug.Indent;
d := GARCH.LikelihoodFunctionValue;
Debug.WriteLine("Value" + d.ToString);
Debug.Unindent;
Debug.WriteLine("Standard error");
Debug.Indent;
d := GARCH.SummaryStatistics.SE;
Debug.WriteLine("Value: " + d.ToString);
Debug.Unindent;
Debug.WriteLine("Modeling series");
Print(GARCH.Fitted);
Debug.WriteLine("Residual series");
Print(GARCH.Residuals);
Debug.WriteLine("Residual variance");
Print(GARCH.ResidualsDispersion);
Debug.WriteLine("Residual variance forecast");
Print(GARCH.ResidualsDispersionForecast);
Debug.WriteLine("Regression coefficient estimation");
RegrCoef := GARCH.RegressionCoefficients.Coefficients;
Debug.Indent;
Debug.WriteLine("Estimated model coefficient values: ");
Print(RegrCoef.Estimate);
Debug.WriteLine("Probabilistic coefficients: ");
Print(RegrCoef.Probability);
Debug.Unindent;
Debug.WriteLine("Estimated coefficients of conditional heteroscedasticity generalized autoregression");
GARCHCoef := GARCH.GARCHCoefficients.Coefficients;
Debug.Indent;
Debug.WriteLine("Estimated model coefficient values: ");
Print(GARCHCoef.Estimate);
Debug.WriteLine("Probabilistic coefficients: ");
Print(GARCHCoef.Probability);
Debug.Unindent;
End If;
End Sub UserProc;
After executing the example the console window displays results of GARCH model calculation.
See also: