Add: ISlQualitySet;
The Add method adds a row into a table.
This example describes setting calculation parameters for the Binary Regression method. Add a link to the system assembly Stat.
Sub UserProc;
Var
bm: SmBinaryModel;
can: Array Of Double;
bin2: Array Of Integer;
mm: Integer;
i, res: Integer;
Intercept: IIntercept;
Explanatories: ISlSeries;
GuessingTable: ISlQualityTable;
GuessTableItem, GTableCom: ISlQualitySet;
Begin
// Set explanatory series values
can := New double[9];
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 := New integer[5];
bin2[00] := 1; bin2[03] := 0;
bin2[01] := 1; bin2[04] := 0;
bin2[02] := 0;
bm := New SmBinaryModel.Create;
// 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 := 14;
// Select constant estimation method
Intercept := bm.ModelCoefficients.Intercept;
Intercept.Mode := InterceptMode.AutoEstimate;
// Select missing data treatment method
bm.MissingData.Method := MissingDataMethod.SampleAverage;
// Select 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;
Explanatories.Item(0).Include := True;
// Perform calculation and display error messages
bm.Execute;
Debug.WriteLine(bm.Errors);
// Display calculation results
If (res = 0) Then
// Table of binary model fitting quality
Debug.WriteLine("Fitting quality description");
GuessingTable := bm.GuessingTable;
GTableCom := GuessingTable.Add;
For mm := 0 To 1 Do
GuessTableItem := GuessingTable.Item(mm);
i := GuessTableItem.Actual;
GTableCom.Actual := GTableCom.Actual + i;
Debug.WriteLine(mm.ToString + ". Fact: " + i.ToString);
i := GuessTableItem.Prediction;
GTableCom.Prediction := GTableCom.Prediction + i;
Debug.WriteLine(mm.ToString + ". Predicted: " + i.ToString);
i := GuessTableItem.CorrectPrediction;
Debug.WriteLine(mm.ToString + ". Predicted correctly: " + i.ToString);
GTableCom.CorrectPrediction := GTableCom.CorrectPrediction + i;
End For;
Debug.WriteLine("Total:");
Debug.WriteLine(" Fact: " + GTableCom.Actual.ToString);
Debug.WriteLine(" Predicted: " + GTableCom.Prediction.ToString);
Debug.WriteLine(" Predicted correctly: " + GTableCom.CorrectPrediction.ToString);
GuessingTable.Remove(GuessingTable.Count - 1);
End If;
End Sub UserProc;
After executing the example calculation parameters are set. The console window displays calculation results and values describing quality of binary model selection. Generalized values of fitting quality are to be added, but after the output to console window they are to be deleted.
Module execution started
No errors
Selection quality description
0. Fact: 3
0. Predicted: 3
0. Predicted correctly: 2
1. Fact: 2
1. Predicted: 2
1. Predicted correctly: 1
Total:
Fact: 5
Predicted: 5
Predicted correctly: 3
Module execution finished
See also: