BinaryForecast: Array;
BinaryForecast: System.Array;
The BinaryForecast property returns a binary forecasting series.
To get a binary modeling series, use the ISmBinaryModel.BinaryFitted property.
To get a forecasting series, use the ISmBinaryModel.Forecast property.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
bm: SmBinaryModel;
can: Array[9] Of Double;
bin2: Array[5] Of Integer;
i, res: Integer;
Intercept: IIntercept;
Explanatories: ISlSeries;
Begin
bm := New SmBinaryModel.Create;
// Set values of explanatory series
can[00] := 6.209; can[05] := 5;
can[01] := 6.385; can[06] := 6;
can[02] := 6.29; can[07] := 7;
can[03] := 6.25; can[08] := 8;
can[04] := 6.1;
// Set explained series values
bin2[00] := 1; bin2[03] := 0;
bin2[01] := 1; bin2[04] := 0;
bin2[02] := 0;
// Set values for the first and the last points of the identification period
bm.ModelPeriod.FirstPoint := 1;
bm.ModelPeriod.LastPoint := 5;
// Set value for the last forecast point
bm.Forecast.LastPoint := 9;
// Set model type
bm.BinaryDistr := BinaryDistrType.Probit;
// Set value of group division and accuracy
bm.ClassificationCutOff := 0.5;
bm.Tolerance := 0.001;
// Set explained series
bm.BinaryExplained := bin2;
// Set explanatory series
Explanatories := bm.Explanatories;
Explanatories.Add.Value := can;
// Set method of calculating the constant
Intercept := bm.ModelCoefficients.Intercept;
Intercept.Mode := InterceptMode.AutoEstimate;
// Perform calculation and display error messages
res:=bm.Execute;
// Display calculation results
If (res = 0) Then
Debug.WriteLine(" === Modeling series ===");
For i := 0 To bm.Fitted.Length - 1 Do
Debug.WriteLine(bm.Fitted[i]);
End For;
Debug.WriteLine(" === Binary modeling series ===");
For i := 0 To bm.BinaryFitted.Length - 1 Do
Debug.WriteLine(bm.BinaryFitted[i]);
End For;
Debug.WriteLine(" === Probability modeling series ===");
For i := 0 To bm.ProbabilityFitted.Length - 1 Do
Debug.WriteLine(bm.ProbabilityFitted[i]);
End For;
Debug.WriteLine(" === Forecast series ===");
For i := 0 To bm.Forecast.Value.Length - 1 Do
Debug.WriteLine(bm.Forecast.Value[i]);
End For;
Debug.WriteLine(" === Binary forecasting series ===");
For i := 0 To bm.BinaryForecast.Length - 1 Do
Debug.WriteLine(bm.BinaryForecast[i]);
End For;
Debug.WriteLine(" === Probability forecasting series ===");
For i := 0 To bm.ProbabilityForecast.Length - 1 Do
Debug.WriteLine(bm.ProbabilityForecast[i]);
End For;
Else
Debug.WriteLine(bm.Errors);
End If;
End Sub UserProc;
After executing the example the console window displays: modeling series, binary modeling series, probabilistic modeling series, forecasting series, binary forecasting series, and probabilistic forecasting series.
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
bm: SmBinaryModel;
can: Array[9] Of Double;
bin2: Array[5] Of Integer;
i, res: Integer;
Intercept: IIntercept;
Explanatories: ISlSeries;
Fitted, BinFitted, ProbFitted, Forecast, BinForecast, ProbForecast: System.Array;
Begin
bm := New SmBinaryModel.Create();
// Set values of explanatory series
can[00] := 6.209; can[05] := 5;
can[01] := 6.385; can[06] := 6;
can[02] := 6.29; can[07] := 7;
can[03] := 6.25; can[08] := 8;
can[04] := 6.1;
// Set explained series values
bin2[00] := 1; bin2[03] := 0;
bin2[01] := 1; bin2[04] := 0;
bin2[02] := 0;
// Set values for the first and the last points of the identification period
bm.ModelPeriod.FirstPoint := 1;
bm.ModelPeriod.LastPoint := 5;
// Set value for the last forecast point
bm.Forecast.LastPoint := 9;
// Set model type
bm.BinaryDistr := BinaryDistrType.bdtProbit;
// Set value of group division and accuracy
bm.ClassificationCutOff := 0.5;
bm.Tolerance := 0.001;
// Set explained series
bm.BinaryExplained := bin2;
// Set explanatory series
Explanatories := bm.Explanatories;
Explanatories.Add().Value := can;
// Set method of calculating the constant
Intercept := bm.ModelCoefficients.Intercept;
Intercept.Mode := InterceptMode.imAutoEstimate;
// Perform calculation and display error messages
res:=bm.Execute();
// Display calculation results
If (res = 0) Then
System.Diagnostics.Debug.WriteLine(" === Model series ===");
Fitted := bm.Fitted;
For i := 0 To bm.Fitted.Length - 1 Do
System.Diagnostics.Debug.WriteLine(Fitted[i]);
End For;
System.Diagnostics.Debug.WriteLine(" === Binary model series ===");
BinFitted := bm.BinaryFitted;
For i := 0 To bm.BinaryFitted.Length - 1 Do
System.Diagnostics.Debug.WriteLine(BinFitted[i]);
End For;
System.Diagnostics.Debug.WriteLine(" === Probabilistic model series ===");
ProbFitted := bm.ProbabilityFitted;
For i := 0 To bm.ProbabilityFitted.Length - 1 Do
System.Diagnostics.Debug.WriteLine(ProbFitted[i]);
End For;
System.Diagnostics.Debug.WriteLine(" === Forecast series ===");
Forecast := bm.Forecast.Value;
For i := 0 To bm.Forecast.Value.Length - 1 Do
System.Diagnostics.Debug.WriteLine(Forecast[i]);
End For;
System.Diagnostics.Debug.WriteLine(" === Binary forecasting series ===");
BinForecast := bm.BinaryForecast;
For i := 0 To bm.BinaryForecast.Length - 1 Do
System.Diagnostics.Debug.WriteLine(BinForecast[i]);
End For;
System.Diagnostics.Debug.WriteLine(" === Probabilistic forecasting series ===");
ProbForecast := bm.ProbabilityForecast;
For i := 0 To bm.ProbabilityForecast.Length - 1 Do
System.Diagnostics.Debug.WriteLine(ProbForecast[i]);
End For;
Else
System.Diagnostics.Debug.WriteLine(bm.Errors);
End If;
End Sub;
See also: