Fitted: Array;
Fitted: System.Array;
The Fitted property returns an array of modeling series values.
Values are available after method calculation.
Add a link to the Stat system assembly.
Sub Print(Data: Array Of Double);
Var
i: Integer;
d: Double;
Begin
For i := 0 To Data.Length - 1 Do
If Double.IsNan(Data[i]) Then
Debug.WriteLine(i.ToString + ", ---empty---");
Else
d := Data[i];
Debug.WriteLine(i.ToString + ", " + d.ToString);
End If;
End For;
End Sub Print;
Sub UserProc;
Var
ar1, ar2: Array[0..15] Of Double;
j, res: Integer;
vars: ISmVectorAutoRegress;
Eqs: ISlEquations;
Eq: ISlEquation;
ARO: Array[0..0] Of Integer;
Begin
vars := New SmVectorAutoRegress.Create;
// Set values for variables
ar1[0] := 3; ar2[0] := 5;
ar1[1] := 8; ar2[1] := 3;
ar1[2] := 12; ar2[2] := 9;
ar1[3] := 10; ar2[3] := 13;
ar1[4] := 26; ar2[4] := 25;
ar1[5] := 21; ar2[5] := 21;
ar1[6] := 35; ar2[6] := 30;
ar1[7] := 29; ar2[7] := 33;
ar1[8] := 40; ar2[8] := 43;
ar1[9] := 39; ar2[9] := 37;
ar1[10] := 51; ar2[10] := 49;
ar1[11] := 50; ar2[11] := 47;
ar1[12] := 59; ar2[12] := 60;
ar1[13] := 58; ar2[13] := 59;
ar1[14] := 65; ar2[14] := 69;
ar1[15] := 72; ar2[15] := 68;
ARO[0] := 1;
Eqs := vars.Equations;
Eq := Eqs.Add;
// Determine explained series
Eq.Serie.Value := ar1;
// Determine autoregression orders
Eq.AutoRegressionOrder := ARO;
// Determine forecasting parameters
Eq.Forecast.LastPoint := 16;
// Determine parameters of equation constant
Eq.Intercept.Mode := InterceptMode.AutoEstimate;
Eq := Eqs.Add;
// Determine explained series
Eq.Serie.Value := ar2;
// Determine autoregression orders
Eq.AutoRegressionOrder := ARO;
// Determine forecasting parameters
Eq.Forecast.LastPoint := 16;
// Determine parameters of equation constant
Eq.Intercept.Mode := InterceptMode.AutoEstimate;
// Define parameters of sample period
vars.ModelPeriod.FirstPoint := 1;
vars.ModelPeriod.LastPoint := 16;
// Run calculation and show results
res := vars.Execute;
If res <> 0 Then
Debug.Writeline(vars.Errors);
Else
For j := 0 To Eqs.Count - 1 Do
Debug.WriteLine("=== Modeling series for equation " + j.ToString + " ===");
Print(Eqs.Item(j).Fitted);
End For;
End If;
End Sub UserProc;
After executing the example the console window displays modeling series of vector autoregression equations.
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 Print(Data: System.Array);
Var
i: Integer;
d: Double;
Begin
For i := 0 To Data.Length - 1 Do
If Double.IsNan(Data.GetValue(i) As Double) Then
System.Diagnostics.Debug.WriteLine(i.ToString() + ", ---empty---");
Else
d := Data.GetValue(i) As Double;
System.Diagnostics.Debug.WriteLine(i.ToString() + ", " + d.ToString());
End If;
End For;
End Sub Print;
Public Shared Sub Main(Params: StartParams);
Var
ar1, ar2: Array[0..15] Of Double;
i, res: Integer;
vars: ISmVectorAutoRegress;
Eqs: ISlEquations;
Eq: ISlEquation;
ARO: Array[0..0] Of Integer;
Begin
vars := New SmVectorAutoRegress.Create();
// Set values for variables
ar1[0] := 3; ar2[0] := 5;
ar1[1] := 8; ar2[1] := 3;
ar1[2] := 12; ar2[2] := 9;
ar1[3] := 10; ar2[3] := 13;
ar1[4] := 26; ar2[4] := 25;
ar1[5] := 21; ar2[5] := 21;
ar1[6] := 35; ar2[6] := 30;
ar1[7] := 29; ar2[7] := 33;
ar1[8] := 40; ar2[8] := 43;
ar1[9] := 39; ar2[9] := 37;
ar1[10] := 51; ar2[10] := 49;
ar1[11] := 50; ar2[11] := 47;
ar1[12] := 59; ar2[12] := 60;
ar1[13] := 58; ar2[13] := 59;
ar1[14] := 65; ar2[14] := 69;
ar1[15] := 72; ar2[15] := 68;
ARO[0] := 1;
Eqs := vars.Equations;
Eq := Eqs.Add();
// Determine explained series
Eq.Serie.Value := ar1;
// Determine autoregression orders
Eq.AutoRegressionOrder := ARO;
// Determine forecasting parameters
Eq.Forecast.LastPoint := 16;
// Determine parameters of equation constant
Eq.Intercept.Mode := InterceptMode.imAutoEstimate;
Eq := Eqs.Add();
// Determine explained series
Eq.Serie.Value := ar2;
// Determine autoregression orders
Eq.AutoRegressionOrder := ARO;
// Determine forecasting parameters
Eq.Forecast.LastPoint := 16;
// Determine parameters of equation constant
Eq.Intercept.Mode := InterceptMode.imAutoEstimate;
// Define parameters of sample period
vars.ModelPeriod.FirstPoint := 1;
vars.ModelPeriod.LastPoint := 16;
// Run calculation and show results
res := vars.Execute();
If res <> 0 Then
System.Diagnostics.Debug.Writeline(vars.Errors);
Else
For i := 0 To Eqs.Count - 1 Do
System.Diagnostics.Debug.WriteLine("=== Modeling series for equation " + i.ToString() + " ===");
Print(Eqs.Item[i].Fitted);
End For;
End If;
End Sub;
See also: