ARMA: ISlARMA;
ARMA: Prognoz.Platform.Interop.Stat.ISlARMA;
The property is read-only.
The ARMA property returns autoregression and moving average parameters.
Be default, autoregression order and moving average order are not specified.
If autoregression or moving average order is set for a model, upper and lower dynamic confidence limits of forecasting series are calculated.
Executing the example requires that the repository contains a modeling container with the MS identifier, containing a model with the MODEL_2SLS identifier. This model must be calculated by the Linear Regression (Instrumental Variables Estimation) method.
Add links to the Metabase, Ms, Stat system assemblies.
Sub UserProc;
Var
MB: IMetabase;
hModel: IMetabaseObjectDescriptor;
oModel: IMsModel;
oTransform: IMsFormulaTransform;
oSelector: IMsFormulaTransformSelector;
oOutputVariable: IMsFormulaTransformVariable;
SLS: IMs2SLSTransform;
ARMA: ISlARMA;
coo: IMsFormulaTransformCoord;
calc: IMsMethodCalculation;
per: IMsModelPeriod;
AR, MR: Array[1] Of Integer;
CoefficientsAR, CoefficientsMA: ICoefficients;
Begin
MB := MetabaseClass.Active;
// Get linear regression model
hModel := MB.ItemByIdNamespace("MODEL_2SLS", MB.GetObjectKeyById("MS"));
oModel := hModel.Edit As IMsModel;
// Get calculation parameters
oTransform := oModel.Transform;
oSelector := oTransform.CreateSelector;
// Get output variable
oOutputVariable := oTransform.Outputs.Item(0) As IMsFormulaTransformVariable;
oSelector.Slice := oOutputVariable.Slices.Item(0);
// Set up linear regression calculation
SLS := oTransform.Transform(oSelector).Method As IMs2SLSTransform;
ARMA := SLS.ARMA;
// Determine autoregression order
AR[0] := 3;
ARMA.OrderAR := AR;
// Set moving average order
MR[0] := 2;
ARMA.OrderMA := MR;
// Set maximum number of iterations
ARMA.MaxIteration := 30;
// Set accuracy of solution
ARMA.Tolerance := 0.5;
// Specify that on calculating confidence limits we do not consider
// that coefficients are found approximately
SLS.CoefUncertaintyInSECalc := False;
// Set the parameters of missing data treatment
SLS.MissingData.Method := MissingDataMethod.LinTrend;
// Identify coefficients
coo := oTransform.CreateCoord(oOutputVariable);
calc := oTransform.CreateCalculation;
per := calc.Period;
per.IdentificationStartDate := oModel.Period.IdentificationStartDate;
per.IdentificationEndDate := oModel.Period.IdentificationEndDate;
per.ForecastStartDate := oModel.Period.ForecastStartDate;
per.ForecastEndDate := oModel.Period.ForecastEndDate;
calc.CurrentPoint := oModel.Period.IdentificationStartDate;
SLS.Identify(calc, coo);
// Get autoregression coefficients
CoefficientsAR := SLS.ARMACoefficients(coo).CoefficientsAR;
Debug.WriteLine("Coefficients of autoregression");
Debug.Write(" Value: ");
Debug.WriteLine(CoefficientsAR.Estimate[0]);
Debug.Write(" Standard error: ");
Debug.WriteLine(CoefficientsAR.StandardError[0]);
Debug.Write(" t-statistic: ");
Debug.WriteLine(CoefficientsAR.TStatistic[0]);
Debug.Write(" Probability:");
Debug.WriteLine(CoefficientsAR.Probability[0]);
// Get moving average coefficients
CoefficientsMA := SLS.ARMACoefficients(coo).CoefficientsMA;
Debug.WriteLine("Coefficients of moving average");
Debug.Write(" Value: ");
Debug.WriteLine(CoefficientsMA.Estimate[0]);
Debug.Write(" Standard error: ");
Debug.WriteLine(CoefficientsMA.StandardError[0]);
Debug.Write(" t-statistic: ");
Debug.WriteLine(CoefficientsMA.TStatistic[0]);
Debug.Write(" Probability:");
Debug.WriteLine(CoefficientsMA.Probability[0]);
(oModel As IMetabaseObject).Save;
End Sub UserProc;
After executing the example autoregression and moving average orders are determined for the model. The maximum number of iterations, accuracy of solution, missing data treatment method and calculation parameters of confidence limits, and so on are changed. The values of summary statistics that are calculated for coefficients of autoregression and moving average are displayed in the console window.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Stat;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
hModel: IMetabaseObjectDescriptor;
oModel: IMsModel;
oTransform: IMsFormulaTransform;
oSelector: IMsFormulaTransformSelector;
oOutputVariable: IMsFormulaTransformVariable;
SLS: IMs2SLSTransform;
ARMA: ISlARMA;
coo: IMsFormulaTransformCoord;
calc: IMsMethodCalculation;
per: IMsModelPeriod;
AR, MR: Array[1] Of Integer;
CoefficientsAR, CoefficientsMA: ICoefficients;
Estimate, Probability, StandardError, TStatistic: System.Array;
Begin
MB := Params.Metabase;
// Get linear regression model
hModel := MB.ItemByIdNamespace["MODEL_2SLS", MB.GetObjectKeyById("MS")];
oModel := hModel.Edit() As IMsModel;
// Get calculation parameters
oTransform := oModel.Transform;
oSelector := oTransform.CreateSelector();
// Get output variable
oOutputVariable := oTransform.Outputs.Item[0] As IMsFormulaTransformVariable;
oSelector.Slice := oOutputVariable.Slices.Item[0];
// Set up linear regression calculation
SLS := oTransform.Transform[oSelector].Method As IMs2SLSTransform;
ARMA := SLS.ARMA;
// Determine autoregression order
AR[0] := 3;
ARMA.OrderAR := AR;
// Set moving average order
MR[0] := 2;
ARMA.OrderMA := MR;
// Set maximum number of iterations
ARMA.MaxIteration := 30;
// Set accuracy of solution
ARMA.Tolerance := 0.5;
// Specify that on calculating confidence limits we do not consider
// that coefficients are found approximately
SLS.CoefUncertaintyInSECalc := False;
// Set the parameters of missing data treatment
SLS.MissingData.Method := MissingDataMethod.mdmLinTrend;
// Identify coefficients
coo := oTransform.CreateCoord(oOutputVariable);
calc := oTransform.CreateCalculation();
per := calc.Period;
per.IdentificationStartDate := oModel.Period.IdentificationStartDate;
per.IdentificationEndDate := oModel.Period.IdentificationEndDate;
per.ForecastStartDate := oModel.Period.ForecastStartDate;
per.ForecastEndDate := oModel.Period.ForecastEndDate;
calc.CurrentPoint := oModel.Period.IdentificationStartDate;
SLS.Identify(calc, coo);
// Get autoregression coefficients
CoefficientsAR := SLS.ARMACoefficients[coo].CoefficientsAR;
Estimate := CoefficientsAR.Estimate;
Probability := CoefficientsAR.Probability;
StandardError := CoefficientsAR.StandardError;
TStatistic := CoefficientsAR.TStatistic;
System.Diagnostics.Debug.WriteLine("Autoregression coefficients");
System.Diagnostics.Debug.Write(" Value: ");
System.Diagnostics.Debug.WriteLine(Estimate[0]);
System.Diagnostics.Debug.Write(" Standard error: ");
System.Diagnostics.Debug.WriteLine(StandardError[0]);
System.Diagnostics.Debug.Write(" t statistics: ");
System.Diagnostics.Debug.WriteLine(TStatistic[0]);
System.Diagnostics.Debug.Write(" Probability:");
System.Diagnostics.Debug.WriteLine(Probability[0]);
// Get moving average coefficients
CoefficientsMA := SLS.ARMACoefficients[coo].CoefficientsMA;
Estimate := CoefficientsMA.Estimate;
Probability := CoefficientsMA.Probability;
StandardError := CoefficientsMA.StandardError;
TStatistic := CoefficientsMA.TStatistic;
System.Diagnostics.Debug.WriteLine("Moving average coefficients");
System.Diagnostics.Debug.Write(" Value: ");
System.Diagnostics.Debug.WriteLine(Estimate[0]);
System.Diagnostics.Debug.Write(" Standard error: ");
System.Diagnostics.Debug.WriteLine(StandardError[0]);
System.Diagnostics.Debug.Write(" t statistics: ");
System.Diagnostics.Debug.WriteLine(TStatistic[0]);
System.Diagnostics.Debug.Write(" Probability:");
System.Diagnostics.Debug.WriteLine(Probability[0]);
(oModel As IMetabaseObject).Save();
End Sub;
See also: