Coefficients: ICoefficients;
Coefficients: Prognoz.Platform.Interop.Stat.ICoefficients;
The Coefficients property determines coefficients' parameters.
To determine parameters of the model constant, use the IModelCoefficients.Intercept 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(LR.Errors);
Debug.WriteLine("-----Model coefficients:");
For i := 0 To Coefficients.Estimate.Length - 1 Do
Debug.WriteLine(Coefficients.Estimate[i]);
End For;
Debug.WriteLine("-----Probability of coefficients:");
For i := 0 To Coefficients.Probability.Length - 1 Do
Debug.WriteLine(Coefficients.Probability[i]);
End For;
Debug.WriteLine("-----Standard coefficient errors:");
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;
Debug.WriteLine("-----Model constant:");
Debug.WriteLine(Intercept.Estimate);
End Sub UserProc;
As a result of the example execution, the following settings are defined:
Method of missing data treatment.
Parameters of coefficients.
Parameters of model coefficients.
The console window displays values of coefficients and constants.
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
arima: ISmLinearRegress;
Intercept: IIntercept;
ModelCoefficients: IModelCoefficients;
Coefficients: ICoefficients;
Explanatories: ISlSerie;
Coef: System.Array;
can, fra: Array[10] Of Double;
res, i: Integer;
Begin
arima := 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
arima.Explained.Value := can;
// Set explanatory variables
arima.Explanatories.Clear();
Explanatories := arima.Explanatories.Add();
Explanatories.Value := fra;
// Missing data treatment
arima.MissingData.Method := MissingDataMethod.mdmLinInterpolation;
// Parameters of coefficients
ModelCoefficients := arima.ModelCoefficients;
Coefficients := ModelCoefficients.Coefficients;
// Parameters of model constant
Intercept := ModelCoefficients.Intercept;
Intercept.Mode := InterceptMode.imAutoEstimate;
res := arima.Execute();
System.Diagnostics.Debug.WriteLine(arima.Errors);
System.Diagnostics.Debug.WriteLine("-----Model coefficients:");
Coef := Coefficients.Estimate;
For i := 0 To Coefficients.Estimate.Length - 1 Do
System.Diagnostics.Debug.WriteLine(Coef[i]);
End For;
System.Diagnostics.Debug.WriteLine("----- Coefficient probabilities:");
Coef := Coefficients.Probability;
For i := 0 To Coefficients.Probability.Length - 1 Do
System.Diagnostics.Debug.WriteLine(Coef[i]);
End For;
System.Diagnostics.Debug.Write("-----Standard coefficient errors:");
Coef := Coefficients.StandardError;
For i := 0 To Coefficients.StandardError.Length - 1 Do
System.Diagnostics.Debug.WriteLine(Coef[i]);
End For;
System.Diagnostics.Debug.WriteLine("----- t-statistics of coefficients:");
Coef := Coefficients.TStatistic;
For i := 0 To Coefficients.TStatistic.Length - 1 Do
System.Diagnostics.Debug.WriteLine(Coef[i]);
End For;
System.Diagnostics.Debug.WriteLine("-----Model constant:");
System.Diagnostics.Debug.WriteLine(Intercept.Estimate);
End Sub;
See also: