Estimate: Array;
Estimate: System.Array;
The Estimate property returns an array of estimated values of model coefficients.
To get the array of coefficients probability values, use the ICoefficients.Probability property.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
LR: ISmLinearRegress;
Intercept: IIntercept;
ModelCoefficients: IModelCoefficients;
Coefficients: ICoefficients;
can, fra: Array[10] Of Double;
res, i: Integer;
Begin
LR := New SmLinearRegress.Create;
// Set values for variables
Can[0] := 6209; fra[0] := 4110;
Can[1] := 6385; fra[1] := 4280;
Can[2] := 6495; fra[2] := 4459;
Can[3] := 6837; fra[3] := 4545;
Can[4] := 6495; fra[4] := 4664;
Can[5] := 6907; fra[5] := 4861;
Can[6] := 7349; fra[6] := 5195;
Can[7] := 7213; fra[7] := 5389;
Can[8] := 7061; fra[8] := 5463;
Can[9] := 7180; fra[9] := 5610;
// Set explained variable
LR.Explained.Value := can;
// Set explanatory variables
LR.Explanatories.Clear;
LR.Explanatories.Add.Value := fra;
// Missing data treatment
LR.MissingData.Method := MissingDataMethod.LinInterpolation;
// Parameters of coefficients
ModelCoefficients := LR.ModelCoefficients;
Coefficients := ModelCoefficients.Coefficients;
// Parameters of model constant
Intercept := ModelCoefficients.Intercept;
Intercept.Mode := InterceptMode.AutoEstimate;
res := LR.Execute;
Debug.WriteLine("=== Model coefficients ===");
For i := 0 To Coefficients.Estimate.Length - 1 Do
Debug.WriteLine(Coefficients.Estimate[i]);
End For;
Debug.WriteLine("=== Coefficient probabilities ===");
For i := 0 To Coefficients.Probability.Length - 1 Do
Debug.WriteLine(Coefficients.Probability[i]);
End For;
Debug.WriteLine("=== Standard errors of coefficients ===");
For i := 0 To Coefficients.StandardError.Length - 1 Do
Debug.WriteLine(Coefficients.StandardError[i]);
End For;
Debug.WriteLine("=== t-statistics of coefficients ===");
For i := 0 To Coefficients.TStatistic.Length - 1 Do
Debug.WriteLine(Coefficients.TStatistic[i]);
End For;
End Sub UserProc;
After executing the example the console window displays coefficient values:
=== Model coefficients===
0,675652218575972
=== Coefficient probabilities ===
3,21885272861033E-04
=== Standard errors of coefficients ===
0,112530025662791
=== t-statistics of coefficients ===
6,00419501014458
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
LR: ISmLinearRegress;
Intercept: IIntercept;
ModelCoefficients: IModelCoefficients;
Coefficients: ICoefficients;
Estimate, Probability, StandardError, TStatistic: System.Array;
can, fra: Array[10] Of Double;
res, i: Integer;
Begin
LR := New SmLinearRegress.Create();
// Set values fornbsp;variables
Can[0] := 6209; fra[0] := 4110;
Can[1] := 6385; fra[1] := 4280;
Can[2] := 6495; fra[2] := 4459;
Can[3] := 6837; fra[3] := 4545;
Can[4] := 6495; fra[4] := 4664;
Can[5] := 6907; fra[5] := 4861;
Can[6] := 7349; fra[6] := 5195;
Can[7] := 7213; fra[7] := 5389;
Can[8] := 7061; fra[8] := 5463;
Can[9] := 7180; fra[9] := 5610;
// Set explained variable
LR.Explained.Value := can;
// Set explanatory variables
LR.Explanatories.Clear();
LR.Explanatories.Add().Value := fra;
// Missing data treatment
LR.MissingData.Method := MissingDataMethod.mdmLinInterpolation;
// Parameters of coefficients
ModelCoefficients := LR.ModelCoefficients;
Coefficients := ModelCoefficients.Coefficients;
// Parameters of model constant
Intercept := ModelCoefficients.Intercept;
Intercept.Mode := InterceptMode.imAutoEstimate;
res := LR.Execute();
Estimate := Coefficients.Estimate;
Probability := Coefficients.Probability;
StandardError := Coefficients.StandardError;
TStatistic := Coefficients.TStatistic;
System.Diagnostics.Debug.WriteLine("=== Model coefficients ===");
For i := 0 To Estimate.Length - 1 Do
System.Diagnostics.Debug.WriteLine(Estimate[i]);
End For;
System.Diagnostics.Debug.WriteLine("=== Coefficient probabilities ===");
For i := 0 To Probability.Length - 1 Do
System.Diagnostics.Debug.WriteLine(Probability[i]);
End For;
System.Diagnostics.Debug.WriteLine("=== Standard errors of coefficients ===");
For i := 0 To StandardError.Length - 1 Do
System.Diagnostics.Debug.WriteLine(StandardError[i]);
End For;
System.Diagnostics.Debug.WriteLine("=== t-statistics of coefficients ===");
For i := 0 To TStatistic.Length - 1 Do
System.Diagnostics.Debug.WriteLine(TStatistic[i]);
End For;
End Sub;
See also: