FStatistic: ISpecificationTestStatistic;
The FStatistic property returns Fisher statistics value.
To get Engle statistics value, use the ISmBreuschPaganGodfreyTest.ObsR2 property.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
BPG: SmBreuschPaganGodfreyTest;
SESS: ISpecificationTestStatistic;
ModelCoef: ICoefficients;
can, fra, ger: Array[10] Of Double;
i, res: Integer;
Begin
BPG := New SmBreuschPaganGodfreyTest.Create;
// Set values of variables
Can[0] := 6209; fra[0] := 4110; ger[0] := 3415;
Can[1] := 6385; fra[1] := 4280; ger[1] := 3673;
Can[2] := Double.Nan; fra[2] := 4459; ger[2] := 4013;
Can[3] := 6837; fra[3] := 4545; ger[3] := 4278;
Can[4] := 6495; fra[4] := 4664; ger[4] := 4577;
Can[5] := 6907; fra[5] := 4861; ger[5] := 5135;
Can[6] := 7349; fra[6] := 5195; ger[6] := 5388;
Can[7] := 7213; fra[7] := 5389; ger[7] := 5610;
Can[8] := 7061; fra[8] := 5463; ger[8] := 5787;
Can[9] := 7180; fra[9] := 5610; ger[9] := 6181;
// Explained data series
BPG.Explained.Value := can;
// Explanatory series
BPG.Explanatories.Clear;
BPG.Explanatories.Add.Value := fra;
// Explanatory series for auxiliary regression
BPG.AdditionalExplanatories.Clear;
BPG.AdditionalExplanatories.Add.Value := ger;
//Estimation of constant
BPG.ModelCoefficients.Intercept.Mode := InterceptMode.AutoEstimate;
// Set orders of autoregression and moving average
BPG.ARMA.ParseAR("3");
BPG.ARMA.ParseMA("2");
// Method of missing data treatment
BPG.MissingData.Method := MissingDataMethod.LinTrend;
// Sample period
BPG.ModelPeriod.FirstPoint := 1;
BPG.ModelPeriod.LastPoint := 10;
res := bpg.Execute;
For i := 0 To BPG.WarningsCount - 1 Do
Debug.WriteLine(BPG.Warnings[i]);
End For;
SESS := BPG.ScaledExplainedSS;
ModelCoef := BPG.ModelCoefficients.Coefficients;
Debug.WriteLine("The Fisher statistics: ");
Debug.Indent;
Debug.WriteLine("Statistics value: " + BPG.FStatistic.Statistic.ToString);
Debug.WriteLine("Probability value: " + BPG.FStatistic.Probability.ToString);
Debug.Unindent;
Debug.WriteLine("The Engle statistics: ");
Debug.Indent;
Debug.WriteLine("Statistics value: " + BPG.ObsR2.Statistic.ToString);
Debug.WriteLine("Probability value: " + BPG.ObsR2.Probability.ToString);
Debug.Unindent;
Debug.WriteLine("Statistics of adjusted error of regression: ");
Debug.Indent;
Debug.WriteLine("Statistics value: " + SESS.Statistic.ToString);
Debug.WriteLine("Probability value: " + SESS.Probability.ToString);
Debug.Unindent;
Debug.WriteLine("===Auxiliary regression===");
Debug.WriteLine("Estimates of auxiliary regression coefficients");
Debug.Indent;
Debug.WriteLine(BPG.ModelCoefficients.Intercept.Estimate.ToString + " " +
BPG.ModelCoefficients.Intercept.StandardError.ToString + " " +
BPG.ModelCoefficients.Intercept.TStatistic.ToString + " " +
BPG.ModelCoefficients.Intercept.Probability.ToString);
For i := 0 To BPG.ModelCoefficients.Coefficients.Estimate.Length - 1 Do
Debug.WriteLine("Estimated values of cofficients: " + ModelCoef.Estimate[i].ToString);
Debug.WriteLine("Standard errors of coefficients: " + ModelCoef.StandardError[i].ToString);
Debug.WriteLine("t-statistics of coefficients: " + ModelCoef.TStatistic[i].ToString);
Debug.WriteLine("Probabilities of coefficients: " + ModelCoef.Probability[i].ToString);
End For;
Debug.Unindent;
Debug.WriteLine("Characteristics of auxiliary regression");
Debug.Indent;
Debug.WriteLine("Determination coefficient: " + BPG.SummaryStatistics.R2.ToString);
Debug.WriteLine("Adjusted determination coefficient: " + BPG.SummaryStatistics.AdjR2.ToString);
Debug.WriteLine("Standard regression error: " + BPG.SummaryStatistics.SE.ToString);
Debug.WriteLine("Sum of residuals squares: " + BPG.SummaryStatistics.SSR.ToString);
Debug.WriteLine("Durbin-Watson statistic: " + BPG.SummaryStatistics.DW.ToString);
Debug.Unindent;
Debug.WriteLine("Model series of auxiliary regression");
Debug.Indent;
For i := 0 To BPG.Fitted.Length - 1 Do
Debug.Write(i.ToString + " ");
Debug.WriteLine(BPG.Fitted[i]);
End For;
Debug.Unindent;
Debug.WriteLine("Residuals series of auxiliary regression");
Debug.Indent;
For i := 0 To BPG.Residuals.Length - 1 Do
Debug.Write(i.ToString + " ");
Debug.WriteLine(BPG.Residuals[i]);
End For;
Debug.Unindent;
End Sub UserProc;
After executing the example the console window displays calculation results of the Breusch-Pagan-Godfrey test for heteroscedasticity.
See also: