CoefficientsMatrix: Array;
CoefficientsMatrix: System.Array;
The CoefficientsMatrix returns matrix of coefficients estimates.
To get estimate characteristics, use the ISmRollingRegression.StandartErrorMatrix, ISmRollingRegression.TStatisticMatrix, ISmRollingRegression.PValueMatrix properties.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
RR: SmRollingRegression;
Explanatories: ISlSerie;
can, fra, ger: Array[10] Of Double;
i, j, res, rows, cols: Integer;
Begin
RR := New SmRollingRegression.Create;
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 series
RR.Explained.Value := can;
// explanatory series
RR.Explanatories.Clear;
Explanatories := RR.Explanatories.Add;
Explanatories.Value := fra;
Explanatories := RR.Explanatories.Add;
Explanatories.Value := ger;
// sample period
RR.ModelPeriod.FirstPoint := 1;
RR.ModelPeriod.LastPoint := 10;
// method of missing data treatment - linear trend
RR.MissingData.Method := MissingDataMethod.LinTrend;
// window shift interval
RR.RollingStep := 1;
// the width of rolling regression window
RR.Window := 4;
// model constant - constant is estimated automatically
RR.Intercept.Mode := InterceptMode.AutoEstimate;
res := RR.Execute;
If res = 0 Then
For i := 0 To RR.WarningsCount - 1 Do
Debug.WriteLine(RR.Warnings[i])
End For;
Debug.WriteLine("==Coefficients==");
rows := RR.CoefficientsMatrix.GetUpperBound(1);
cols := RR.CoefficientsMatrix.GetUpperBound(2);
Debug.Indent;
For i := 0 To rows Do
For j := 0 To cols Do
Debug.Write(RR.CoefficientsMatrix[i, j]);
End For;
Debug.WriteLine(" ");
End For;
Debug.Unindent;
Debug.WriteLine("==Standard errors==");
rows := RR.StandartErrorMatrix.GetUpperBound(1);
cols := RR.StandartErrorMatrix.GetUpperBound(2);
Debug.Indent;
For i := 0 To rows Do
For j := 0 To cols Do
Debug.Write(RR.StandartErrorMatrix[i, j]);
End For;
Debug.WriteLine(" ");
End For;
Debug.Unindent;
Debug.WriteLine("==Statistics==");
rows := RR.TStatisticMatrix.GetUpperBound(1);
cols := RR.TStatisticMatrix.GetUpperBound(2);
Debug.Indent;
For i := 0 To rows Do
For j := 0 To cols Do
Debug.Write(RR.TStatisticMatrix[i, j]);
End For;
Debug.WriteLine(" ");
End For;
Debug.Unindent;
Debug.WriteLine("==Probability==");
rows := RR.PValueMatrix.GetUpperBound(1);
cols := RR.PValueMatrix.GetUpperBound(2);
Debug.Indent;
For i := 0 To rows Do
For j := 0 To cols Do
Debug.Write(RR.PValueMatrix[i, j]);
End For;
Debug.WriteLine(" ");
End For;
Debug.Unindent;
Debug.WriteLine("==Forecast series==");
Debug.Indent;
For i := 0 To RR.RollingForecast.Length - 1 Do
Debug.Write(i.ToString + " ");
Debug.WriteLine(RR.RollingForecast[i]);
End For;
Debug.Unindent;
Else
Debug.WriteLine(RR.Errors);
End If;
End Sub UserProc;
After executing the example a rolling regression model with the following parameters is created:
Sample period is set manually.
The width of rolling regression window is four.
Window shift interval is one.
The console window displays matrix of coefficients estimation, statistic, probability, standard errors and forecasting series.
The requirements and result of executing the Fore.NET Example match those of the Fore Example.
Imports Prognoz.Platform.Interop.Stat;
…
Public Shared Sub Main(Params: StartParams);
Var
RR := New SmRollingRegressionClass.Create();
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;
//explained series
RR.Explained.Value := can;
// explanatory series
RR.Explanatories.Clear();
Explanatories := RR.Explanatories.Add();
Explanatories.Value := fra;
Explanatories := RR.Explanatories.Add();
Explanatories.Value := ger;
// sample period
RR.ModelPeriod.FirstPoint := 1;
RR.ModelPeriod.LastPoint := 10;
// method of missing data treatment - linear trend
RR.MissingData.Method := MissingDataMethod.mdmLinTrend;
// window shift interval
RR.RollingStep := 1;
// the width of rolling regression window
RR.Window := 4;
// model constant - constant is estimated automatically
RR.Intercept.Mode := InterceptMode.imAutoEstimate;
res := RR.Execute();
If res = 0 Then
Warnings := RR.Warnings;
For i := 0 To RR.WarningsCount - 1 Do
System.Diagnostics.Debug.WriteLine(Warnings[i])
End For;
System.Diagnostics.Debug.WriteLine("==Coefficients==");
rows := RR.CoefficientsMatrix.GetUpperBound(0);
cols := RR.CoefficientsMatrix.GetUpperBound(1);
CoefMatr := RR.CoefficientsMatrix;
System.Diagnostics.Debug.Indent();
For i := 0 To rows Do
For j := 0 To cols Do
System.Diagnostics.Debug.Write(CoefMatr[i, j]);
System.Diagnostics.Debug.Write(" ");
End For;
System.Diagnostics.Debug.WriteLine(" ");
End For;
System.Diagnostics.Debug.Unindent();
System.Diagnostics.Debug.WriteLine("==Standard errors==");
rows := RR.StandartErrorMatrix.GetUpperBound(0);
cols := RR.StandartErrorMatrix.GetUpperBound(1);
StEr := RR.StandartErrorMatrix;
System.Diagnostics.Debug.Indent();
For i := 0 To rows Do
For j := 0 To cols Do
System.Diagnostics.Debug.Write(StEr[i, j]);
System.Diagnostics.Debug.Write(" ");
End For;
System.Diagnostics.Debug.WriteLine(" ");
End For;
System.Diagnostics.Debug.Unindent();
System.Diagnostics.Debug.WriteLine("==Statistics==");
rows := RR.TStatisticMatrix.GetUpperBound(0);
cols := RR.TStatisticMatrix.GetUpperBound(1);
TStat := RR.TStatisticMatrix;
System.Diagnostics.Debug.Indent();
For i := 0 To rows Do
For j := 0 To cols Do
System.Diagnostics.Debug.Write(TStat[i, j]);
System.Diagnostics.Debug.Write(" ");
End For;
System.Diagnostics.Debug.WriteLine(" ");
End For;
System.Diagnostics.Debug.Unindent();
System.Diagnostics.Debug.WriteLine("==Probability==");
rows := RR.PValueMatrix.GetUpperBound(0);
cols := RR.PValueMatrix.GetUpperBound(1);
PVal := RR.PValueMatrix;
System.Diagnostics.Debug.Indent();
For i := 0 To rows Do
For j := 0 To cols Do
System.Diagnostics.Debug.Write(PVal[i, j]);
System.Diagnostics.Debug.Write(" ");
End For;
System.Diagnostics.Debug.WriteLine(" ");
End For;
System.Diagnostics.Debug.Unindent();
System.Diagnostics.Debug.WriteLine("==Forecast series==");
Forecast := RR.RollingForecast;
System.Diagnostics.Debug.Indent();
For i := 0 To RR.RollingForecast.Length - 1 Do
System.Diagnostics.Debug.Write(i.ToString() + " ");
System.Diagnostics.Debug.WriteLine(Forecast[i]);
End For;
System.Diagnostics.Debug.Unindent();
Else
System.Diagnostics.Debug.WriteLine(RR.Errors);
End If;
End Sub;
See also: