ParseAR(Value: String; [AssignOrder: Boolean = True]);
Value. String representation of autoregression order.
AssignOrder. Indicates, whether the obtained value is set into the ISlARMA.OrderAR property.
The ParseAR method parses string representation of autoregression order.
The Value parameter should contain numbers or ranges of autoregression orders, separated with commas. For example:
ParseAR("1-3,5,7-9");
If AssignOrder = True, after executing the ParseAR the obtained value is set into theISlARMA.OrderAR property. If AssignOrder = False, autoregression order does not change.
To execute the example, add a link to the Stat system assembly.
Sub UserARMA;
Var
lr: ISmLinearRegress;
W: Array[15] Of Double;
x: Array[20] Of Double;
ARMA: ISlARMA;
res: Integer;
d: Double;
CoefficientsAR, CoefficientsMA: ICoefficients;
ModelCoefficients: IModelCoefficients;
Begin
lr := New SmLinearRegress.Create;
// explained series values
w[0] := 2; w[4] := -1.9; w[8] := -0.7; w[12] := 5.4;
w[1] := 0.8; w[5] := Double.Nan; w[9] := Double.Nan; w[13] := 6.4;
w[2] := -0.3; w[6] := 3.2; w[10] := 4.3; w[14] := 7.4;
w[3] := -0.3; w[7] := 1.6; w[11] := 1.1;
// 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;
// Sample period
lr.ModelPeriod.FirstPoint := 1;
lr.ModelPeriod.LastPoint := 13;
lr.Forecast.LastPoint := 19;
lr.MissingData.Method := MissingDataMethod.LinTrend;
lr.Explained.Value := w;
lr.Explanatories.Add.Value := x;
ModelCoefficients := lr.ModelCoefficients;
// a constant is used in the model
ModelCoefficients.Intercept.Mode := InterceptMode.AutoEstimate;
ModelCoefficients.Intercept.InitValue := 2;
ARMA := lr.ARMA;
// autoregression order
ARMA.ParseAR("2");
// moving average order
ARMA.ParseMA("1");
// Method of determining initial approximations
ARMA.CalcInitMode := ARMAInitType.Auto;
// use backcast to estimate moving average coefficients
ARMA.EstimationApproach := ARMAEstimationApproach.LeastSquares;
ARMA.UseBackCast := True;
// optimization method
ARMA.EstimationMethod := ARMAEstimationMethodType.GaussNewton;
// model calculation
res := lr.Execute;
Debug.WriteLine(lr.Errors);
If (res = 0) Then
// autoregression coefficients
Debug.WriteLine("Autoregression coefficients' estimates");
CoefficientsAR := ARMA.CoefficientsAR;
d := CoefficientsAR.Estimate[0];
Debug.WriteLine(" Value: " + d.ToString);
d := CoefficientsAR.StandardError[0];
Debug.WriteLine(" Standard error: " + d.ToString);
d := CoefficientsAR.TStatistic[0];
//Moving average coefficients' estimates
Debug.WriteLine("Moving average coefficients' estimates");
CoefficientsMA := ARMA.CoefficientsMA;
d := CoefficientsMA.Estimate[0];
Debug.WriteLine(" Value: " + d.ToString);
d := CoefficientsMA.StandardError[0];
Debug.WriteLine(" Standard error: " + d.ToString);
End If;
End Sub UserARMA;
After executing the example a linear regression model is created and its parameters are defined. Autoregression and moving average orders are to be parsed from string view. Backcast is used to estimate moving average coefficients. The console window displays estimations of model coefficients.
See also: