ARRootsIm: Array;
ARRootsIm: System.Array;
The ARRootsIm property returns values of imaginary part of AR process characteristic roots.
To get values of real part of AR process characteristic roots, use the ISlARMA.ARRootsRe property.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
lr: ISmLinearRegress;
x: Array[30] Of Double;
Intercept: IIntercept;
res, i: Integer;
d: Double;
CoefficientsAR: ICoefficients;
Begin
lr := New SmLinearRegress.Create;
// Values of explained series:
x[0]:=0.00576; x[1]:=0.0078; x[2]:=0.00851; x[3]:=0.00691;
x[4]:=0.00585; x[5]:=0.00127; x[6]:=-0.00431; x[7]:=0.00305;
x[8]:=0.00455; x[9]:=0.00829; x[10]:=0.01095; x[11]:=0.0042;
x[12]:=0.00172; x[13]:=0.00221; x[14]:=0.00685; x[15]:=0.00317;
x[16]:=0.00073; x[17]:=0.00267; x[18]:=0.00073; x[19]:=0.00218;
x[20]:=0.0041; x[21]:=-0.00144; x[22]:=-0.00507; x[23]:=0.00964;
x[24]:=0.00455; x[25]:=0.00334; x[26]:=0.00166; x[27]:=0.00781;
x[28]:=0.01055; x[29]:=0.00512;
lr.Explained.Value := x;
// Sample period:
lr.ModelPeriod.FirstPoint := 1;
lr.ModelPeriod.LastPoint := 20;
lr.Forecast.LastPoint := 30;
// A constant will be used in the model:
Intercept:= lr.ModelCoefficients.Intercept;
Intercept.Mode := InterceptMode.ManualEstimate;
// ARIMA options:
lr.ARMA.ParseAR("2");
// Method of initial approximations detection:
lr.ARMA.CalcInitMode := ARMAInitType.Auto;
// Optimization method:
lr.ARMA.EstimationMethod := ARMAEstimationMethodType.GaussNewton;
// Number of iterations and accuracy for optimization method:
lr.ARMA.MaxIteration := 500;
lr.ARMA.Tolerance := 0.000100;
// Calculate model:
res := lr.Execute;
If (res = 0) Then
Debug.WriteLine("===Autoregression coefficients estimates===");
CoefficientsAR := lr.ARMA.CoefficientsAR;
For i:=0 To CoefficientsAR.Estimate.Length-1 Do
d := CoefficientsAR.Estimate[i];
Debug.WriteLine("Value: " + d0.ToString);
d := CoefficientsAR.StandardError[i];
Debug.WriteLine("Standard error: " + d.ToString);
d := CoefficientsAR.TStatistic[i];
Debug.WriteLine("t-statistic: " + d.ToString);
d := CoefficientsAR.Probability[i];
Debug.WriteLine("Probability: " + d.ToString);
End For;
//Characteristic roots:
Debug.WriteLine("AR roots:");
For i:=0 To lr.ARMA.ARRootsRe.Length-1 Do
Debug.WriteLine((lr.ARMA.ARRootsRe[i] As Double).ToString + " + " + (lr.ARMA.ARRootsIm[i] As Double).ToString + "i");
End For;
Else
Debug.WriteLine(lr.Errors);
End If;
End Sub UserProc;
After executing the example the console window displays estimates of autoregression coefficients and AR roots.
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;
x: Array[30] Of Double;
Intercept: IIntercept;
res, i: Integer;
CoefficientsAR: ICoefficients;
d, RootsRe, RootsIm: System.Array;
Begin
lr := New SmLinearRegress.Create();
// Values of explained series:
x[0]:=0.00576; x[1]:=0.0078; x[2]:=0.00851; x[3]:=0.00691;
x[4]:=0.00585; x[5]:=0.00127; x[6]:=-0.00431; x[7]:=0.00305;
x[8]:=0.00455; x[9]:=0.00829; x[10]:=0.01095; x[11]:=0.0042;
x[12]:=0.00172; x[13]:=0.00221; x[14]:=0.00685; x[15]:=0.00317;
x[16]:=0.00073; x[17]:=0.00267; x[18]:=0.00073; x[19]:=0.00218;
x[20]:=0.0041; x[21]:=-0.00144; x[22]:=-0.00507; x[23]:=0.00964;
x[24]:=0.00455; x[25]:=0.00334; x[26]:=0.00166; x[27]:=0.00781;
x[28]:=0.01055; x[29]:=0.00512;
lr.Explained.Value := x;
// Sample period:
lr.ModelPeriod.FirstPoint := 1;
lr.ModelPeriod.LastPoint := 20;
lr.Forecast.LastPoint := 30;
// A constant will be used in the model:
Intercept:= lr.ModelCoefficients.Intercept;
Intercept.Mode := InterceptMode.imManualEstimate;
// ARIMA options:
lr.ARMA.ParseAR("2", True);
// Method of initial approximations detection:
lr.ARMA.CalcInitMode := ARMAInitType.armaitAuto;
// Optimization method:
lr.ARMA.EstimationMethod := ARMAEstimationMethodType.armaemtGaussNewton;
// Number of iterations and accuracy for optimization method:
lr.ARMA.MaxIteration := 500;
lr.ARMA.Tolerance := 0.000100;
// Calculate model:
res := lr.Execute();
If (res = 0) Then
System.Diagnostics.Debug.WriteLine("===Autoregression coefficients estimates===");
CoefficientsAR := lr.ARMA.CoefficientsAR;
For i:=0 To CoefficientsAR.Estimate.Length-1 Do
d := CoefficientsAR.Estimate;
System.Diagnostics.Debug.WriteLine("Value: " + d[i].ToString());
d := CoefficientsAR.StandardError;
System.Diagnostics.Debug.WriteLine("Standard error: " + d[i].ToString());
d := CoefficientsAR.TStatistic;
System.Diagnostics.Debug.WriteLine("t-statistic: " + d[i].ToString());
d := CoefficientsAR.Probability;
System.Diagnostics.Debug.WriteLine("Probability: " + d[i].ToString());
End For;
//Characteristic roots:
System.Diagnostics.Debug.WriteLine("AR roots:");
RootsRe := lr.ARMA.ARRootsRe;
RootsIm := lr.ARMA.ARRootsIm;
For i:=0 To lr.ARMA.ARRootsRe.Length-1 Do
System.Diagnostics.Debug.WriteLine((RootsRe[i] As Double).ToString() + " + " + (RootsIm[i] As Double).ToString() + "i");
End For;
Else
System.Diagnostics.Debug.WriteLine(lr.Errors);
End If;
End Sub;
See also: