CoefficientsARSeas: ICoefficients;
The CoefficientsARSeas property returns seasonal autoregression coefficients.
The coefficients are estimated if the order of seasonal autoregression is defined in ISlARMA.OrderARSeas.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
lr: ISmLinearRegress;
W: Array[20] Of Double;
ARMA: ISlARMA;
Inits: Array[2] Of Double;
res: Integer;
d: Double;
CoefficientsAR, CoefficientsMA: ICoefficients;
ModelCoefficients: IModelCoefficients;
i: Integer;
Forecast: Array Of Double;
Begin
lr := New SmLinearRegress.Create;
// explained series values
w[0] := 2; w[4] := -1.9; w[8] := -0.7; w[12] := 5.4; w[16] := 2.8;
w[1] := 0.8; w[5] := Double.Nan; w[9] := Double.Nan; w[13] := 6.4;w[17] := 0.8;
w[2] := -0.3; w[6] := 3.2; w[10] := 4.3; w[14] := 7.4; w[18] := -0.7;
w[3] := -0.3; w[7] := 1.6; w[11] := 1.1;w[15] := 2;w[19] := Double.Nan;
// Sample period
lr.ModelPeriod.FirstPoint := 1;
lr.ModelPeriod.LastPoint := 13;
lr.Forecast.LastPoint := 19;
lr.MissingData.Method := MissingDataMethod.AnyValue;
lr.Explained.Value := w;
ModelCoefficients := lr.ModelCoefficients;
// a constant is used in the model
ModelCoefficients.Intercept.Mode := InterceptMode.AutoEstimate;
ARMA := lr.ARMA;
// seasonal autoregression order
ARMA.ParseARSeas("1");
// seasonal moving average order
ARMA.ParseMASeas("1");
// seasonal autoregression initial approximations
Inits[0] := 0.0025;
ARMA.InitARSeas := Inits;
// initial approximations of seasonal moving average
Inits[0] := 0.0035;
ARMA.InitMASeas := Inits;
// seasonal difference
ARMA.DiffSeas := 0;
// seasonality period
ARMA.PeriodSeas := 4;
// difference
ARMA.Diff := 2;
// optimization method
ARMA.EstimationMethod := ARMAEstimationMethodType.LevenbergMarquardt;
// model calculation
res := lr.Execute;
Debug.WriteLine(lr.Errors);
If (res = 0) Then
// forecast values
Forecast := lr.Forecast.Value;
Debug.WriteLine("Forecast values:"); Debug.Indent;
For i := 0 To Forecast.Length - 1 Do
Debug.WriteLine(Forecast[i]);
End For;
Debug.Unindent;
// seasonal autoregression coefficients
Debug.WriteLine("Seasonal autoregression coefficients' estimates");
CoefficientsAR := ARMA.CoefficientsARSeas;
d := CoefficientsAR.Estimate[0];
Debug.WriteLine(" Value: " + d.ToString);
d := CoefficientsAR.Probability[0];
Debug.WriteLine(" Probability: " + d.ToString);
// seasonal moving average coefficients
Debug.WriteLine("Seasonal moving average coefficients' estimates");
CoefficientsMA := ARMA.CoefficientsMASeas;
d := CoefficientsMA.Estimate[0];
Debug.WriteLine(" Value: " + d.ToString);
d := CoefficientsMA.Probability[0];
Debug.WriteLine(" Probability: " + d.ToString);
End If;
End Sub UserProc;
After executing the example a linear regression model is created and its parameters are defined. Seasonal autoregression and seasonal moving average orders are to be parsed from string representation. The console window displays forecast values and estimates of model coefficients.
See also: