Fitted: Array;
Fitted: System.Array;
The Fitted property returns a modeling series.
Values are available after method calculation.
Add a link to the Stat system assembly.
Sub UserProc;
Var
ChowTest: SmChowTest;
can, fra, ger, d0: Array Of Double;
z: Array Of Integer;
res, i: Integer;
LR: IChowTestLinRegress;
Begin
ChowTest := New SmChowTest.Create;
can := New Double[20];
fra := New Double[20];
ger := New Double[20];
z := New Integer[20];
// Set values for variables
can[00] := 6209; fra[00] := 4110; ger[00] := 3415; z[00] := 0;
can[01] := 6385; fra[01] := 4280; ger[01] := 6385; z[01] := 0;
can[02] := 6752; fra[02] := 4459; ger[02] := 6752; z[02] := 0;
can[03] := 6837; fra[03] := 4545; ger[03] := 6837; z[03] := 0;
can[04] := 6495; fra[04] := 4664; ger[04] := 6495; z[04] := 0;
can[05] := 6907; fra[05] := 4861; ger[05] := 6907; z[05] := 0;
can[06] := 7349; fra[06] := 5195; ger[06] := 7349; z[06] := 0;
can[07] := 7213; fra[07] := 5389; ger[07] := 7213; z[07] := 0;
can[08] := 7061; fra[08] := 5463; ger[08] := 7061; z[08] := 0;
can[09] := 7180; fra[09] := 5610; ger[09] := 7180; z[09] := 0;
can[10] := 7132; fra[10] := 5948; ger[10] := 7132; z[10] := 0;
can[11] := 7137; fra[11] := 6218; ger[11] := 7137; z[11] := 0;
can[12] := 7473; fra[12] := 6521; ger[12] := 7473; z[12] := 1;
can[13] := 7722; fra[13] := 6788; ger[13] := 7722; z[13] := 1;
can[14] := 8088; fra[14] := 7222; ger[14] := 8088; z[14] := 1;
can[15] := 8516; fra[15] := 7486; ger[15] := 8516; z[15] := 1;
can[16] := 8941; fra[16] := 7832; ger[16] := 8941; z[16] := 1;
can[17] := 9064; fra[17] := 8153; ger[17] := 9064; z[17] := 1;
can[18] := 9380; fra[18] := 8468; ger[18] := 9380; z[18] := 1;
can[19] := 9746; fra[19] := 9054; ger[19] := 9746; z[19] := 1;
// Set explained variable
ChowTest.Explained.Value := can;
// Set explanatory variables
ChowTest.Explanatories.Add.Value := fra;
ChowTest.Explanatories.Add.Value := ger;
// Set observation groups
ChowTest.GroupSeparator := z;
// Use auto estimation of constant value
ChowTest.Intercept.Mode := InterceptMode.AutoEstimate;
// Set sample period parameters
ChowTest.ModelPeriod.FirstPoint := 1;
ChowTest.ModelPeriod.LastPoint := 20;
// Set test type
ChowTest.TestType := ChowTestType.BreakPoint;
// Run calculation and show results
res := ChowTest.Execute;
If res <> 0 Then
Debug.WriteLine(ChowTest.Errors);
Else
If ChowTest.ChowTestResult Then
Debug.WriteLine("Zero hypothesis is accepted")
Else
Debug.WriteLine("Zero hypothesis is rejected");
End If;
Debug.WriteLine("Modeling series:");
Debug.WriteLine("LR0:");
LR := ChowTest.LR0;
For i := 0 To LR.Fitted.Length - 1 Do
Debug.WriteLine(LR.Fitted[i]);
End For;
Debug.WriteLine("LR1:");
LR := ChowTest.LR1;
For i := 0 To LR.Fitted.Length - 1 Do
Debug.WriteLine(LR.Fitted[i]);
End For;
Debug.WriteLine("Residuals:");
Debug.WriteLine("LR0:");
LR := ChowTest.LR0;
For i := 0 To LR.Residuals.Length - 1 Do
Debug.WriteLine(LR.Residuals[i]);
End For;
Debug.WriteLine("LR1:");
LR := ChowTest.LR1;
For i := 0 To LR.Residuals.Length - 1 Do
Debug.WriteLine(LR.Residuals[i]);
End For;
Debug.WriteLine("Akaike criterion:");
Debug.WriteLine("LR0: " + ChowTest.LR0.SummaryStatistics.AIC.ToString);
Debug.WriteLine("LR1: " + ChowTest.LR1.SummaryStatistics.AIC.ToString);
End If;
End Sub UserProc;
After executing the example the console window displays test calculation results: modeling series, residuals and summary statistics, a message that zero hypothesis about absence of structural changes is not accepted.
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
ChowTest: SmChowTest;
can, fra, ger, d0: Array Of Double;
z: Array Of Integer;
res, i: Integer;
LR: IChowTestLinRegress;
Fitted, Residuals: System.Array;
Begin
ChowTest := New SmChowTest.Create();
can := New Double[20];
fra := New Double[20];
ger := New Double[20];
z := New Integer[20];
// Set values for variables
can[00] := 6209; fra[00] := 4110; ger[00] := 3415; z[00] := 0;
can[01] := 6385; fra[01] := 4280; ger[01] := 6385; z[01] := 0;
can[02] := 6752; fra[02] := 4459; ger[02] := 6752; z[02] := 0;
can[03] := 6837; fra[03] := 4545; ger[03] := 6837; z[03] := 0;
can[04] := 6495; fra[04] := 4664; ger[04] := 6495; z[04] := 0;
can[05] := 6907; fra[05] := 4861; ger[05] := 6907; z[05] := 0;
can[06] := 7349; fra[06] := 5195; ger[06] := 7349; z[06] := 0;
can[07] := 7213; fra[07] := 5389; ger[07] := 7213; z[07] := 0;
can[08] := 7061; fra[08] := 5463; ger[08] := 7061; z[08] := 0;
can[09] := 7180; fra[09] := 5610; ger[09] := 7180; z[09] := 0;
can[10] := 7132; fra[10] := 5948; ger[10] := 7132; z[10] := 0;
can[11] := 7137; fra[11] := 6218; ger[11] := 7137; z[11] := 0;
can[12] := 7473; fra[12] := 6521; ger[12] := 7473; z[12] := 1;
can[13] := 7722; fra[13] := 6788; ger[13] := 7722; z[13] := 1;
can[14] := 8088; fra[14] := 7222; ger[14] := 8088; z[14] := 1;
can[15] := 8516; fra[15] := 7486; ger[15] := 8516; z[15] := 1;
can[16] := 8941; fra[16] := 7832; ger[16] := 8941; z[16] := 1;
can[17] := 9064; fra[17] := 8153; ger[17] := 9064; z[17] := 1;
can[18] := 9380; fra[18] := 8468; ger[18] := 9380; z[18] := 1;
can[19] := 9746; fra[19] := 9054; ger[19] := 9746; z[19] := 1;
// Set explained variable
ChowTest.Explained.Value := can;
// Set explanatory variables
ChowTest.Explanatories.Add().Value := fra;
ChowTest.Explanatories.Add().Value := ger;
// Set observation groups
ChowTest.GroupSeparator := z;
// Use auto estimation of constant value
ChowTest.Intercept.Mode := InterceptMode.imAutoEstimate;
// Set sample period parameters
ChowTest.ModelPeriod.FirstPoint := 1;
ChowTest.ModelPeriod.LastPoint := 20;
// Set test type
ChowTest.TestType := ChowTestType.ctBreakPoint;
// Run calculation and show results
res := ChowTest.Execute();
If res <> 0 Then
System.Diagnostics.Debug.WriteLine(ChowTest.Errors);
Else
If ChowTest.ChowTestResult Then
System.Diagnostics.Debug.WriteLine("Zero hypothesis is accepted")
Else
System.Diagnostics.Debug.WriteLine("Zero hypothesis is not accepted");
End If;
System.Diagnostics.Debug.WriteLine("Modeling series:");
System.Diagnostics.Debug.WriteLine("LR0:");
Fitted := ChowTest.LR0.Fitted;
For i := 0 To ChowTest.LR0.Fitted.Length - 1 Do
System.Diagnostics.Debug.WriteLine(Fitted[i]);
End For;
System.Diagnostics.Debug.WriteLine("LR1:");
Fitted := ChowTest.LR1.Fitted;
For i := 0 To ChowTest.LR1.Fitted.Length - 1 Do
System.Diagnostics.Debug.WriteLine(Fitted[i]);
End For;
System.Diagnostics.Debug.WriteLine("Residuals:");
System.Diagnostics.Debug.WriteLine("LR0:");
Residuals := ChowTest.LR0.Residuals;
For i := 0 To ChowTest.LR0.Residuals.Length - 1 Do
System.Diagnostics.Debug.WriteLine(Residuals[i]);
End For;
System.Diagnostics.Debug.WriteLine("LR1:");
Residuals := ChowTest.LR1.Residuals;
For i := 0 To ChowTest.LR1.Residuals.Length - 1 Do
System.Diagnostics.Debug.WriteLine(Residuals[i]);
End For;
System.Diagnostics.Debug.WriteLine("Akaike criterion:");
System.Diagnostics.Debug.WriteLine("LR0: " + ChowTest.LR0.SummaryStatistics.AIC.ToString());
System.Diagnostics.Debug.WriteLine("LR1: " + ChowTest.LR1.SummaryStatistics.AIC.ToString());
End If;
End Sub;
See also: