ChiTest: ISpecificationTestStatistic;
ChiTest: Prognoz.Platform.Interop.Stat.ISpecificationTestStatistic;
The ChiTest property returns Chi square statistics values.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
RESSET: SmRamseyRESSETTest;
d0: Double;
res, i: Integer;
y, y0, y1, y2: Array[9] Of Double;
v: Array Of Double;
Begin
// Set values for variables
y[0] := 6209; y0[0] := 4110; y1[0] := 3415; y2[0] := 2822;
y[1] := 6385; y0[1] := 4280; y1[1] := 3673; y2[1] := 3023;
y[2] := 6752; y0[2] := 4459; y1[2] := 4013; y2[2] := 3131;
y[3] := Double.Nan; y0[3] := 4545; y1[3] := 4278; y2[3] := 3351;
y[4] := 6495; y0[4] := 4664; y1[4] := 4577; y2[4] := 3463;
y[5] := 6907; y0[5] := 4861; y1[5] := 5135; y2[5] := 3686;
y[6] := 7349; y0[6] := 5195; y1[6] := 5388; y2[6] := 3815;
y[7] := Double.Nan; y0[7] := 5389; y1[7] := 5610; y2[7] := 3960;
y[8] := 7061; y0[8] := 5463; y1[8] := 5787; y2[8] := 4119;
RESSET := New SmRamseyRESSETTest.Create;
// Set explained and explanatory series
RESSET.Explained.Value := y;
RESSET.Explanatories.Add.Value := y0;
RESSET.Explanatories.Add.Value := y1;
RESSET.Explanatories.Add.Value := y2;
// Set calculation periods
RESSET.ModelPeriod.FirstPoint := 1;
RESSET.ModelPeriod.LastPoint := 9;
// Select method of missing data treatment
RESSET.MissingData.Method := MissingDataMethod.LinTrend;
// Set autoregression order
RESSET.ARMA.ParseAR("1");
// Select method of calculating the constant
RESSET.ModelCoefficients.Intercept.Mode := InterceptMode.AutoEstimate;
// Set the number of additional regressors
RESSET.Power := 1;
// Run calculation and show results
res := RESSET.Execute;
If res <> 0 Then
Debug.WriteLine(RESSET.Errors);
Else
Debug.Indent;
Debug.WriteLine("Fisher test");
Debug.Unindent;
d0 := RESSET.FTest.Statistic;
Debug.WriteLine("value: " + d0.ToString);
d0 := RESSET.FTest.Probability;
Debug.WriteLine("probability: " + d0.ToString);
Debug.Indent;
Debug.WriteLine("Chi-square test");
Debug.Unindent;
d0 := RESSET.ChiTest.Statistic;
Debug.WriteLine("value: " + d0.ToString);
d0 := RESSET.ChiTest.Probability;
Debug.WriteLine("probability: " + d0.ToString);
Debug.Indent;
Debug.WriteLine("Model coefficients");
Debug.Unindent;
v := RESSET.ModelCoefficients.Coefficients.Estimate;
For i := 0 To v.Length - 1 Do
Debug.Write(i.ToString + ", ");
Debug.WriteLine(v[i]);
End For;
Debug.Indent;
Debug.WriteLine("Modeling series");
Debug.Unindent;
v := RESSET.Fitted;
For i := 0 To v.Length - 1 Do
Debug.Write(i.ToString + ", ");
Debug.WriteLine(v[i]);
End For;
Debug.Indent;
Debug.WriteLine("Residuals");
Debug.Unindent;
v := RESSET.Residuals;
For i := 0 To v.Length - 1 Do
Debug.Write(i.ToString + ", ");
Debug.WriteLine(v[i]);
End For;
Debug.Indent;
Debug.WriteLine("Constant");
Debug.Unindent;
d0 := RESSET.ModelCoefficients.Intercept.Estimate;
Debug.WriteLine(d0.ToString);
Debug.Indent;
Debug.WriteLine("Summary statistics");
Debug.Unindent;
d0 := RESSET.SummaryStatistics.AIC;
Debug.WriteLine("Akaike criterion: " + d0.ToString);
d0 := RESSET.SummaryStatistics.DW;
Debug.WriteLine("Durbin-Watson statistic: " + d0.ToString);
End If;
End Sub UserProc;
After executing the example the console window displays Fisher test and chi-square test calculation results, the modeling series, the residual series, the constant, and summary statistics.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Stat;
…
Public Shared Sub Main(Params: StartParams);
Var
RESSET: SmRamseyRESSETTest;
d0: Double;
res, i: Integer;
y, y0, y1, y2: Array[9] Of Double;
v: Array;
Begin
// Set values for variables
y[0] := 6209; y0[0] := 4110; y1[0] := 3415; y2[0] := 2822;
y[1] := 6385; y0[1] := 4280; y1[1] := 3673; y2[1] := 3023;
y[2] := 6752; y0[2] := 4459; y1[2] := 4013; y2[2] := 3131;
y[3] := Double.Nan; y0[3] := 4545; y1[3] := 4278; y2[3] := 3351;
y[4] := 6495; y0[4] := 4664; y1[4] := 4577; y2[4] := 3463;
y[5] := 6907; y0[5] := 4861; y1[5] := 5135; y2[5] := 3686;
y[6] := 7349; y0[6] := 5195; y1[6] := 5388; y2[6] := 3815;
y[7] := Double.Nan; y0[7] := 5389; y1[7] := 5610; y2[7] := 3960;
y[8] := 7061; y0[8] := 5463; y1[8] := 5787; y2[8] := 4119;
RESSET := New SmRamseyRESSETTest.Create();
// Set explained and explanatory series
RESSET.Explained.Value := y;
RESSET.Explanatories.Add().Value := y0;
RESSET.Explanatories.Add().Value := y1;
RESSET.Explanatories.Add().Value := y2;
// Set calculation periods
RESSET.ModelPeriod.FirstPoint := 1;
RESSET.ModelPeriod.LastPoint := 9;
// Select method of missing data treatment
RESSET.MissingData.Method := MissingDataMethod.mdmLinTrend;
// Set autoregression order
RESSET.ARMA.ParseAR("1", True);
// Select method of calculating the constant
RESSET.ModelCoefficients.Intercept.Mode := InterceptMode.imAutoEstimate;
// Set the number of additional regressors
RESSET.Power := 1;
// Run calculation and show results
res := RESSET.Execute();
If res <> 0 Then
System.Diagnostics.Debug.WriteLine(RESSET.Errors);
Else
System.Diagnostics.Debug.Indent();
System.Diagnostics.Debug.WriteLine("Fisher test");
System.Diagnostics.Debug.Unindent();
d0 := RESSET.FTest.Statistic;
System.Diagnostics.Debug.WriteLine("value: " + d0.ToString());
d0 := RESSET.FTest.Probability;
System.Diagnostics.Debug.WriteLine("probability: " + d0.ToString());
System.Diagnostics.Debug.Indent();
System.Diagnostics.Debug.WriteLine("Chi-square test");
System.Diagnostics.Debug.Unindent();
d0 := RESSET.ChiTest.Statistic;
System.Diagnostics.Debug.WriteLine("value: " + d0.ToString());
d0 := RESSET.ChiTest.Probability;
System.Diagnostics.Debug.WriteLine("probability: " + d0.ToString());
System.Diagnostics.Debug.Indent();
System.Diagnostics.Debug.WriteLine("Model coefficients");
System.Diagnostics.Debug.Unindent();
v := RESSET.ModelCoefficients.Coefficients.Estimate;
For i := 0 To v.Length - 1 Do
System.Diagnostics.Debug.Write(i.ToString() + ", ");
System.Diagnostics.Debug.WriteLine(v.GetValue(i));
End For;
System.Diagnostics.Debug.Indent();
System.Diagnostics.Debug.WriteLine("Modeling series");
System.Diagnostics.Debug.Unindent();
v := RESSET.Fitted;
For i := 0 To v.Length - 1 Do
System.Diagnostics.Debug.Write(i.ToString() + ", ");
System.Diagnostics.Debug.WriteLine(v.GetValue(i));
End For;
System.Diagnostics.Debug.Indent();
System.Diagnostics.Debug.WriteLine("Residuals");
System.Diagnostics.Debug.Unindent();
v := RESSET.Residuals;
For i := 0 To v.Length - 1 Do
System.Diagnostics.Debug.Write(i.ToString() + ", ");
System.Diagnostics.Debug.WriteLine(v.GetValue(i));
End For;
System.Diagnostics.Debug.Indent();
System.Diagnostics.Debug.WriteLine("Constant");
System.Diagnostics.Debug.Unindent();
d0 := RESSET.ModelCoefficients.Intercept.Estimate;
System.Diagnostics.Debug.WriteLine(d0.ToString());
System.Diagnostics.Debug.Indent();
System.Diagnostics.Debug.WriteLine("Summary statistics");
System.Diagnostics.Debug.Unindent();
d0 := RESSET.SummaryStatistics.AIC;
System.Diagnostics.Debug.WriteLine("Akaike criterion: " + d0.ToString());
d0 := RESSET.SummaryStatistics.DW;
System.Diagnostics.Debug.WriteLine("Durbin-Watson statistic: " + d0.ToString());
End If;
End Sub;
See also: