BinaryForecast: 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;
Debug.WriteLine(" === Classification quality criteria ===");
Debug.WriteLine("Number of truly positive values: " + bm.RelevanceMeasure.TruePositive.ToString);
Debug.WriteLine("Number of truly negative values: " + bm.RelevanceMeasure.TrueNegative.ToString);
Debug.WriteLine("Number of false positive values: " + bm.RelevanceMeasure.FalsePositive.ToString);
Debug.WriteLine("Number of false positive values: " + bm.RelevanceMeasure.FalseNegative.ToString);
Debug.WriteLine("Overall accuracy: " + bm.RelevanceMeasure.Accuracy.ToString);
Debug.WriteLine("F - estimate: " + bm.RelevanceMeasure.F1.ToString);
Debug.WriteLine("Accuracy of positive result: " + bm.RelevanceMeasure.Precision.ToString);
Debug.WriteLine("Completeness of positive result: " + bm.RelevanceMeasure.Recall.ToString);
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, probabilistic forecasting series and classification quality criteria.
See also: