BPTest: ISpecificationTestStatistic;
The BPTest property returns the value of the Breusch-Pagan statistics.
To get summary statistics, use the ISmBreuschPaganTest.SummaryStatistics property.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
BP: SmBreuschPaganTest;
ModelCoef: ICoefficients;
can, fra, ger: Array[43] Of Double;
i, res: Integer;
Begin
BP := New SmBreuschPaganTest.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
BP.Explained.Value := can;
// Explanatory series
BP.Explanatories.Clear;
BP.Explanatories.Add.Value := fra;
// Explanatory series for auxiliary regression
BP.AdditionalExplanatories.Clear;
BP.AdditionalExplanatories.Add.Value := ger;
//Estimation of constant
BP.ModelCoefficients.Intercept.Mode := InterceptMode.AutoEstimate;
// Method of missing data treatment
BP.MissingData.Method := MissingDataMethod.LinTrend;
// Sample period
BP.ModelPeriod.FirstPoint := 1;
BP.ModelPeriod.LastPoint := 10;
// Studentization parameter is accounted
BP.Studentize := True;
res := BP.Execute;
Debug.WriteLine(BP.Errors);
ModelCoef := BP.ModelCoefficients.Coefficients;
Debug.WriteLine("===Breusch-Pagan test statistics===");
Debug.Indent;
Debug.WriteLine("Statistics value: " + BP.BPTest.Statistic.ToString);
Debug.WriteLine("Probability value: " + BP.BPTest.Probability.ToString);
Debug.Unindent;
Debug.WriteLine("===Auxiliary regression===");
Debug.WriteLine("Estimates of auxiliary regression coefficients:");
Debug.WriteLine(BP.ModelCoefficients.Intercept.Estimate.ToString + " " +
BP.ModelCoefficients.Intercept.StandardError.ToString + " " +
BP.ModelCoefficients.Intercept.TStatistic.ToString + " " +
BP.ModelCoefficients.Intercept.Probability.ToString);
For i := 0 To BP.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: " + BP.SummaryStatistics.R2.ToString);
Debug.WriteLine("Adjusted determination coefficient: " + BP.SummaryStatistics.AdjR2.ToString);
Debug.WriteLine("Standard regression error: " + BP.SummaryStatistics.SE.ToString);
Debug.WriteLine("Sum of residuals squares: " + BP.SummaryStatistics.SSR.ToString);
Debug.WriteLine("Durbin-Watson statistic: " + BP.SummaryStatistics.DW.ToString);
Debug.Unindent;
Debug.WriteLine("Model series of auxiliary regression");
Debug.Indent;
For i := 0 To BP.Fitted.Length - 1 Do
Debug.Write(i.ToString + " ");
Debug.WriteLine(BP.Fitted[i]);
End For;
Debug.Unindent;
Debug.WriteLine("Residuals series of auxiliary regression");
Debug.Indent;
For i := 0 To BP.Residuals.Length - 1 Do
Debug.Write(i.ToString + " ");
Debug.WriteLine(BP.Residuals[i]);
End For;
Debug.Unindent;
End Sub UserProc;
After executing the example the console window displays calculation results for the Breusch-Pagan test.
See also: