MissingData: IMissingData;
MissingData: Prognoz.Platform.Interop.Stat.SlMissingData;
The MissingData property determines missing data treatment parameters.
By default missing data is not treated.
Add a link to the Stat system assembly.
Sub Print(Data: Array Of Double);
Var
i: Integer;
Begin
For i := 0 To Data.Length - 1 Do
If Double.IsNan(Data[i]) Then
Debug.WriteLine("---empty---");
Else
Debug.WriteLine(i.ToString + ", " + Data[i].ToString);
End If;
End For;
End Sub Print;
Sub UserProc;
Var
ar: SmAutoRegress;
res: Integer;
y: Array[24] Of Double;
AROrder: Array[3] Of Integer;
d: Double;
Begin
// Set variable values
ar := New SmAutoRegress.Create;
y[00] := 6209; y[12] := Double.Nan;
y[01] := 6385; y[13] := 7722;
y[02] := 6752; y[14] := 8088;
y[03] := 6837; y[15] := 8516;
y[04] := 6495; y[16] := 8941;
y[05] := 6907; y[17] := 9064;
y[06] := 7349; y[18] := 9380;
y[07] := 7213; y[19] := 9746;
y[08] := 7061; y[20] := 9907;
y[09] := 7180; y[21] := 10333;
y[10] := Double.Nan; y[22] := 10863;
y[11] := Double.Nan; y[23] := 11693;
// Determine explained series
ar.Serie.Value := y;
// Define parameters of sample period
ar.ModelPeriod.FirstPoint := 1;
ar.ModelPeriod.LastPoint := 24;
// Determine forecasting series parameters
ar.Forecast.LastPoint := 35;
// Determine autoregression orders
AROrder[0] := 1;
AROrder[1] := 3;
AROrder[2] := 5;
ar.AutoRegressionOrder := AROrder;
// Determine missing data treatment parameters
ar.MissingData.Method := MissingDataMethod.SampleAverage;
// Determine model coefficient parameters
ar.ModelCoefficients.Intercept.Mode := InterceptMode.AutoEstimate;
// Calculate the method and output the results
res := ar.Execute;
If res <> 0 Then
Debug.WriteLine(ar.Errors);
Else
Debug.WriteLine("=== Model series ===");
Print(ar.Fitted);
Debug.WriteLine("=== Forecast series ===");
Print(ar.Forecast.Value);
Debug.WriteLine("=== Residuals ===");
Print(ar.Residuals);
Debug.WriteLine("=== Summary statistics ===");
Debug.WriteLine("=== Determination coefficient ===");
d := ar.SummaryStatistics.AdjR2;
Debug.WriteLine(d);
Debug.WriteLine("=== Mean error ===");
d := ar.SummaryStatistics.ME;
Debug.WriteLine(d);
End If;
End Sub UserProc;
After executing the example the console window displays the modeling and forecasting series, residuals, 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 Print(Data: System.Array);
Var
i: Integer;
Begin
For i := 0 To Data.Length - 1 Do
If Double.IsNan(Data.GetValue(i) As Double) Then
System.Diagnostics.Debug.WriteLine("---empty---");
Else
System.Diagnostics.Debug.WriteLine(i.ToString() + ", " + Data.GetValue(i).ToString());
End If;
End For;
End Sub Print;
Public Shared Sub Main(Params: StartParams);
Var
ar: SmAutoRegress;
res: Integer;
y: Array[24] Of Double;
AROrder: Array[3] Of Integer;
d: Double;
Begin
// Set variable values
ar := New SmAutoRegress.Create();
y[00] := 6209; y[12] := Double.Nan;
y[01] := 6385; y[13] := 7722;
y[02] := 6752; y[14] := 8088;
y[03] := 6837; y[15] := 8516;
y[04] := 6495; y[16] := 8941;
y[05] := 6907; y[17] := 9064;
y[06] := 7349; y[18] := 9380;
y[07] := 7213; y[19] := 9746;
y[08] := 7061; y[20] := 9907;
y[09] := 7180; y[21] := 10333;
y[10] := Double.Nan; y[22] := 10863;
y[11] := Double.Nan; y[23] := 11693;
// Determine explained series
ar.Serie.Value := y;
// Define parameters of sample period
ar.ModelPeriod.FirstPoint := 1;
ar.ModelPeriod.LastPoint := 24;
// Determine forecasting series parameters
ar.Forecast.LastPoint := 35;
// Determine autoregression orders
AROrder[0] := 1;
AROrder[1] := 3;
AROrder[2] := 5;
ar.AutoRegressionOrder := AROrder;
// Determine missing data treatment parameters
ar.MissingData.Method := MissingDataMethod.mdmSampleAverage;
// Determine model coefficient parameters
ar.ModelCoefficients.Intercept.Mode := InterceptMode.imAutoEstimate;
// Calculate the method and output the results
res := ar.Execute();
If res <> 0 Then
System.Diagnostics.Debug.WriteLine(ar.Errors);
Else
System.Diagnostics.Debug.WriteLine("=== Model series ===");
Print(ar.Fitted);
System.Diagnostics.Debug.WriteLine("=== Forecast series ===");
Print(ar.Forecast.Value);
System.Diagnostics.Debug.WriteLine("=== Residuals ===");
Print(ar.Residuals);
System.Diagnostics.Debug.WriteLine("=== Summary statistics ===");
System.Diagnostics.Debug.WriteLine("=== Determination coefficient ===");
d := ar.SummaryStatistics.AdjR2;
System.Diagnostics.Debug.WriteLine(d);
System.Diagnostics.Debug.WriteLine("=== Mean error ===");
d := ar.SummaryStatistics.ME;
System.Diagnostics.Debug.WriteLine(d);
End If;
End Sub;
See also: