UseAnalyticDeriv: Boolean;
The UseAnalyticDeriv property determines whether analytical derivatives are used in solution search.
Available values:
True. Default value. Analytical derivatives are used in search solution.
False. Numeric derivatives are used to search solution.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
lr: ISmLinearRegress;
W: Array[12] Of Double;
X: array[20] Of Double;
ARMA: ISlARMA;
AR, MA: Array[1] Of Integer;
res, i: Integer;
ModelCoefficients: IModelCoefficients;
Begin
lr := New SmLinearRegress.Create;
// explained series values
w[0] := 2; w[4] := -1.9; w[8] := -0.7;
w[1] := 0.8; w[5] := Double.Nan; w[9] := Double.Nan;
w[2] := -0.3; w[6] := 3.2; w[10] := 4.3;
w[3] := -0.3; w[7] := 1.6; w[11] := 1.1;
lr.Explained.Value := w;
// Explanatory series values
x[0] := Double.Nan; x[10] := 11;
x[1] := 2; x[11] := 12;
x[2] := 3; x[12] := 13;
x[3] := 4; x[13] := Double.Nan;
x[4] := 5; x[14] := 15;
x[5] := 6; x[15] := 16;
x[6] := Double.Nan; x[16] := 17;
x[7] := 8; x[17] := Double.Nan;
x[8] := 9; x[18] := 19;
x[9] := 10; x[19] := 20;
lr.Explanatories.Clear;
lr.Explanatories.Add.Value := X;
lr.Explanatories.Item(0).Name := "X";
// Constant is used in model
ModelCoefficients := lr.ModelCoefficients;
ModelCoefficients.Intercept.Mode := InterceptMode.AutoEstimate;
// Sample period
lr.ModelPeriod.FirstPoint := 1;
lr.ModelPeriod.LastPoint := 12;
lr.Forecast.LastPoint := 19;
// Method of missing data treatment
lr.MissingData.Method := MissingDataMethod.AnyValue;
ARMA := lr.ARMA;
// autoregression order
AR[0] := 2;
ARMA.OrderAR := AR;
// moving average order
MA[0] := 1;
ARMA.OrderMA := MA;
// method of initial approximations detection
ARMA.CalcInitMode := ARMAInitType.Auto;
// optimization method
ARMA.EstimationMethod := ARMAEstimationMethodType.LevenbergMarquardt;
// number of iterations and accuracy for optimization method
ARMA.MaxIteration := 50;
ARMA.Tolerance := 0.1;
// Use analytical derivatives in solution search
ARMA.UseAnalyticDeriv := True;
// calculate model
res := lr.Execute;
If (res = 0) Then
Debug.WriteLine(" ===Estimates of model coefficients=== ");
Debug.WriteLine("Constnat: " + ModelCoefficients.Intercept.Estimate.ToString);
For i:=0 To ModelCoefficients.Coefficients.Estimate.Length-1 Do
Debug.WriteLine(lr.Explanatories.Item(i).Name +": " + ModelCoefficients.Coefficients.Estimate[i].ToString);
End For;
For i:=0 To lr.ARMA.CoefficientsAR.Estimate.Length-1 Do
Debug.WriteLine("AR("+Ar[i].ToString +"): " + lr.ARMA.CoefficientsAR.Estimate[i].ToString);
End For;
For i:=0 To lr.ARMA.CoefficientsMA.Estimate.Length-1 Do
Debug.WriteLine("MA("+Ma[i].ToString +"): " + lr.ARMA.CoefficientsMA.Estimate[i].ToString);
End For;
Debug.WriteLine(" ===Descriptive statistics=== ");
Debug.WriteLine("Determination coefficient: " + lr.SummaryStatistics.R2.ToString);
Debug.WriteLine("Sum of residual squares: " + lr.SummaryStatistics.SSR.ToString);
Debug.WriteLine("Standard error: " + lr.SummaryStatistics.SE.ToString);
Else
Debug.WriteLine(lr.Errors);
End If;
End Sub UserProc;
After executing the example the console window displays estimates of model coefficients and descriptive statistics.
See also: