CovarianceMatrix: Array;
The CovarianceMatrix property returns covariance matrix values.
It is required to use an array of the Double type.
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, j, res: Integer;
str: String;
Intercept: IIntercept;
Explanatory: ISlSerie;
OriginalValue, Value: 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.Probit;
// Set value of dividing into groups
bm.ClassificationCutOff := 0.5;
//Use initial values used by default
bm.UseDefaultInitValues := False;
// Set tolerance and maximum number of iterations
bm.Tolerance := 0.001;
bm.MaxIteration := 100;
// Set optimization method
bm.OptimizationMethod := BinaryOptimizationMethod.NewtonRaphson;
// Set method of calculating the constant
Intercept := bm.ModelCoefficients.Intercept;
Intercept.Mode := InterceptMode.ManualEstimate;
Intercept.InitValue := 5;
// Set explained series
bm.BinaryExplained := bin2;
// Set explanatory series
Explanatory := bm.Explanatories.Add;
Explanatory.Id := "Explanatories_can";
Explanatory.Name := "can";
Explanatory.Value := can;
Explanatory.Include := True;
Explanatory.InitValue := 6.44;
// Perform calculation and display error messages
res := bm.Execute;
// Display calculation results
If (res = 0) Then
Debug.WriteLine("Covariance matrix");
For i := 0 To bm.CovarianceMatrix.GetUpperBound(2) Do
str := "";
For j := 0 To bm.CovarianceMatrix.GetUpperBound(1) Do
str := str + " " + (bm.CovarianceMatrix[j, i] As Double).ToString;
End For;
Debug.WriteLine(str);
End For;
Debug.WriteLine("Source series");
For i := 0 To Explanatory.Value.Length - 1 Do
Debug.WriteLine((i + 1).ToString + ". " + Explanatory.OriginalValue[i].ToString);
End For;
End If;
End Sub UserProc;
After executing the example the console window displays covariance matrix and source series.
See also: