InitApproximation: Array;
InitApproximation: System.Array;
The InitApproximation property determines initial approximations.
Indexing of initial approximation array must start with zero.
The property is relevant if ISmLinearEquations.SLEMethod = SLEMethodType.ConjugateGradient.
Add a link to the Stat system assembly.
Sub UserProc;
Var
Method: ISmLinearEquations;
ExplainedVal, Exp1, Exp2: Array[2] Of Double;
ExplanatoriesVal: ISlSeries;
Init: Array[2] Of Double;
Status, i: Integer;
Estimate: Array Of Double;
Begin
Method := New SmLinearEquations.Create;
// explained series values
ExplainedVal[00] := 5;
ExplainedVal[01] := 8;
Method.Explained.Value := ExplainedVal;
// Explanatory series values
ExplanatoriesVal := Method.Explanatories;
Exp1[00] := 3; Exp2[00] := 2;
Exp1[01] := 2; Exp2[01] := 1;
ExplanatoriesVal.Add.Value := Exp1;
ExplanatoriesVal.Add.Value := Exp2;
// Sample period parameters:
Method.ModelPeriod.FirstPoint := 1;
Method.ModelPeriod.LastPoint := 2;
// Parameters of model coefficients:
Method.ModelCoefficients.Intercept.Mode := InterceptMode.None;
// Values of initial approximations:
Init[0] := 0;
Init[1] := 2;
Method.InitApproximation := Init;
// Accuracy and maximum number of iterations:
Method.Tolerance := 0.00001;
Method.MaxIteration := 500;
// Linear equation system solution method:
Method.SLEMethod := SLEMethodType.ConjugateGradient;
// Casting linear equation system to equivalent one:
Method.SymmetricMatrixSet := True;
// Calculate model:
Status := Method.Execute;
Debug.WriteLine(Method.Errors);
Debug.WriteLine("=== Estimated coefficient values ===");
Estimate := Method.ModelCoefficients.Coefficients.Estimate;
For i := 0 To Estimate.Length - 1 Do
Debug.WriteLine((i+1).ToString + ". " + Estimate[i].ToString);
End For;
End Sub UserProc;
After executing the example the console window displays estimated coefficient values.
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
Method: ISmLinearEquations;
ExplainedVal, Exp1, Exp2: Array[2] Of Double;
ExplanatoriesVal: ISlSeries;
Init: Array[2] Of Double;
Status, i: Integer;
Estimate: System.Array;
Begin
Method := New SmLinearEquations.Create();
// explained series values
ExplainedVal[00] := 5;
ExplainedVal[01] := 8;
Method.Explained.Value := ExplainedVal;
// Explanatory series values
ExplanatoriesVal := Method.Explanatories;
Exp1[00] := 3; Exp2[00] := 2;
Exp1[01] := 2; Exp2[01] := 1;
ExplanatoriesVal.Add().Value := Exp1;
ExplanatoriesVal.Add().Value := Exp2;
// Sample period parameters:
Method.ModelPeriod.FirstPoint := 1;
Method.ModelPeriod.LastPoint := 2;
// Parameters of model coefficients:
Method.ModelCoefficients.Intercept.Mode := InterceptMode.imNone;
// Values of initial approximations:
Init[0] := 0;
Init[1] := 2;
Method.InitApproximation := Init;
// Accuracy and maximum number of iterations:
Method.Tolerance := 0.00001;
Method.MaxIteration := 500;
// Linear equation system solution method:
Method.SLEMethod := SLEMethodType.slemtConjugateGradient;
// Casting linear equation system to equivalent one:
Method.SymmetricMatrixSet := True;
// Calculate model:
Status := Method.Execute();
System.Diagnostics.Debug.WriteLine(Method.Errors);
System.Diagnostics.Debug.WriteLine("=== Estimated coefficient values ===");
Estimate := Method.ModelCoefficients.Coefficients.Estimate;
For i := 0 To Estimate.Length - 1 Do
System.Diagnostics.Debug.WriteLine((i+1).ToString() + ". " + Estimate[i].ToString());
End For;
End Sub;
See also: