ARMA: ISlARMA;
ARMA: Prognoz.Platform.Interop.Stat.SlARMA;
The ARMA property returns autoregression and moving average parameters.
By default autoregression order and moving average order are not specified.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
TwoSLS: Sm2SLS;
can, fra, ger: Array[15] Of Double;
AR, MA: Array[1] Of Integer;
C: IIntercept;
MC:ICoefficients;
ARMA: ISlARMA;
res, i: Integer;
Begin
// Create model
TwoSLS := New Sm2SLS.Create;
// Set values fornbsp;variables
can[00] := 6209; fra[00] := 4110; ger[00] := 3415;
can[01] := 6385; fra[01] := 4280; ger[01] := 3673;
can[02] := 6752; fra[02] := 4459; ger[02] := 4013;
can[03] := 6837; fra[03] := 4545; ger[03] := 4278;
can[04] := 6495; fra[04] := 4664; ger[04] := 4577;
can[05] := 6907; fra[05] := 4861; ger[05] := 5135;
can[06] := 7349; fra[06] := 5195; ger[06] := 5388;
can[07] := 7213; fra[07] := 5389; ger[07] := 5610;
can[08] := 7061; fra[08] := 5463; ger[08] := 6181;
can[09] := 7180; fra[09] := 5610; ger[09] := 6181;
can[10] := 7132; fra[10] := 5948; ger[10] := 6633;
can[11] := 7180; fra[11] := 6218; ger[11] := 6910;
can[12] := 7473; fra[12] := 6521; ger[12] := 7146;
can[13] := 7722; fra[13] := 6788; ger[13] := 7248;
can[14] := 8088; fra[14] := 7222; ger[14] := 7689;
// Set sample period parameters
TwoSLS.ModelPeriod.FirstPoint := 1;
TwoSLS.ModelPeriod.LastPoint := 15;
// Use auto estimation of constant value
C:=TwoSLS.ModelCoefficients.Intercept;
C.Mode := InterceptMode.AutoEstimate;
// Set explained variable
TwoSLS.Explained.Value := can;
// Set explanatory variables
TwoSLS.Explanatories.Add.Value := fra;
TwoSLS.Explanatories.Item(0).Name := "fra";
// Set instrumental variables
TwoSLS.Instrumental.Add.Value := ger;
ARMA := TwoSLS.ARMA;
AR[0] := 1;
ARMA.OrderAR := AR;
MA[0] := 2;
ARMA.OrderMA := MA;
// Set maximum number of iterations and solution accuracy
ARMA.MaxIteration := 30;
ARMA.Tolerance := 0.5;
// Use lagged values of explained and explanatory variables
// as additional tools
ARMA.UseARMAasInstrums := True;
// Run calculation and show results
res := TwoSLS.Execute;
If res <> 0 Then
Debug.WriteLine(TwoSLS.Errors);
Else
Debug.WriteLine("=== Model coefficients ===");
Debug.WriteLine("Constant: " + C.Estimate.ToString);
MC := TwoSLS.ModelCoefficients.Coefficients;
For i := 0 To MC.Estimate.Length-1 Do
Debug.WriteLine(TwoSLS.Explanatories.Item(0).Name + ": " + MC.Estimate[i].ToString);
End For;
For i := 0 To ARMA.CoefficientsAR.Estimate.Length-1 Do
Debug.WriteLine("AR(" + AR[i].ToString+"): " + ARMA.CoefficientsAR.Estimate[i].ToString);
End For;
For i := 0 To ARMA.CoefficientsMA.Estimate.Length-1 Do
Debug.WriteLine("MA(" + MA[i].ToString+"): " + ARMA.CoefficientsMA.Estimate[i].ToString);
End For;
Debug.WriteLine(" === Descriptive statistics === ");
Debug.WriteLine("Determination coefficient: " + TwoSLS.SummaryStatistics.R2.ToString);
Debug.WriteLine("Sum of residuals squares: " + TwoSLS.SummaryStatistics.SSR.ToString);
Debug.WriteLine("Standard regression error: " + TwoSLS.SummaryStatistics.SE.ToString);
End If;
End Sub UserProc;
After executing the example the console window displays model coefficients and descriptive statistics.
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
TwoSLS: Sm2SLS;
can, fra, ger: Array[15] Of Double;
AR, MA: Array[1] Of Integer;
C: IIntercept;
MC:ICoefficients;
ARMA: ISlARMA;
res, i: Integer;
Estimate: System.Array;
Begin
// Create model
TwoSLS := New Sm2SLS.Create();
// Set values fornbsp;variables
can[00] := 6209; fra[00] := 4110; ger[00] := 3415;
can[01] := 6385; fra[01] := 4280; ger[01] := 3673;
can[02] := 6752; fra[02] := 4459; ger[02] := 4013;
can[03] := 6837; fra[03] := 4545; ger[03] := 4278;
can[04] := 6495; fra[04] := 4664; ger[04] := 4577;
can[05] := 6907; fra[05] := 4861; ger[05] := 5135;
can[06] := 7349; fra[06] := 5195; ger[06] := 5388;
can[07] := 7213; fra[07] := 5389; ger[07] := 5610;
can[08] := 7061; fra[08] := 5463; ger[08] := 6181;
can[09] := 7180; fra[09] := 5610; ger[09] := 6181;
can[10] := 7132; fra[10] := 5948; ger[10] := 6633;
can[11] := 7180; fra[11] := 6218; ger[11] := 6910;
can[12] := 7473; fra[12] := 6521; ger[12] := 7146;
can[13] := 7722; fra[13] := 6788; ger[13] := 7248;
can[14] := 8088; fra[14] := 7222; ger[14] := 7689;
// Set sample period parameters
TwoSLS.ModelPeriod.FirstPoint := 1;
TwoSLS.ModelPeriod.LastPoint := 15;
// Use auto estimation of constant value
C:=TwoSLS.ModelCoefficients.Intercept;
C.Mode := InterceptMode.imAutoEstimate;
// Set explained variable
TwoSLS.Explained.Value := can;
// Set explanatory variables
TwoSLS.Explanatories.Add().Value := fra;
TwoSLS.Explanatories.Item[0].Name := "fra";
// Set instrumental variables
TwoSLS.Instrumental.Add().Value := ger;
ARMA := TwoSLS.ARMA;
AR[0] := 1;
ARMA.OrderAR := AR;
MA[0] := 2;
ARMA.OrderMA := MA;
// Set maximum number of iterations and solution accuracy
ARMA.MaxIteration := 30;
ARMA.Tolerance := 0.5;
// Use lagged values of explained and explanatory variables
// as additional tools
ARMA.UseARMAasInstrums := True;
// Run calculation and show results
res := TwoSLS.Execute();
If res <> 0 Then
System.Diagnostics.Debug.WriteLine(TwoSLS.Errors);
Else
System.Diagnostics.Debug.WriteLine("=== Models coefficients ===");
System.Diagnostics.Debug.WriteLine("Constant: " + C.Estimate.ToString());
MC := TwoSLS.ModelCoefficients.Coefficients;
For i := 0 To MC.Estimate.Length-1 Do
Estimate := MC.Estimate;
System.Diagnostics.Debug.WriteLine(TwoSLS.Explanatories.Item[0].Name + ": " + Estimate[i].ToString());
End For;
For i := 0 To ARMA.CoefficientsAR.Estimate.Length-1 Do
Estimate := ARMA.CoefficientsAR.Estimate;
System.Diagnostics.Debug.WriteLine("AR(" + AR[i].ToString()+"): " + Estimate[i].ToString());
End For;
For i := 0 To ARMA.CoefficientsMA.Estimate.Length-1 Do
Estimate := ARMA.CoefficientsMA.Estimate;
System.Diagnostics.Debug.WriteLine("MA(" + MA[i].ToString()+"): " + Estimate[i].ToString());
End For;
System.Diagnostics.Debug.WriteLine(" === Descriptive statistics === ");
System.Diagnostics.Debug.WriteLine("Determination coefficient: " + TwoSLS.SummaryStatistics.R2.ToString());
System.Diagnostics.Debug.WriteLine("Sum of residuals squares: " + TwoSLS.SummaryStatistics.SSR.ToString());
System.Diagnostics.Debug.WriteLine("Standard regression error: " + TwoSLS.SummaryStatistics.SE.ToString());
End If;
End Sub;
See also: