ARMA: ISlARMA;
The ARMA property returns autoregression and moving average parameters.
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_LINEARREGR identifier. This model must be calculated by the Linear Regression (Least Squares 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;
oLinear: IMsLinearRegressionTransform;
ARMA: ISlARMA;
pCalc: IMsMethodCalculation;
coo: IMsFormulaTransformCoord;
AR, MR: Array[1] Of Integer;
CoefficientsAR, CoefficientsMA: ICoefficients;
Begin
mb := MetabaseClass.Active;
// Get linear regression model
hModel := mb.ItemByIdNamespace("MODEL_LINEARREGR", mb.GetObjectKeyById("MS"));
oModel := hModel.Edit As IMsModel;
// Get calculation parameters
oTransform := oModel.Transform;
oSelector := oTransform.CreateSelector;
// Get output model
oOutputVariable := oTransform.Outputs.Item(0) As IMsFormulaTransformVariable;
oSelector.Slice := oOutputVariable.Slices.Item(0);
// Set up linear regression calculation
oLinear := oTransform.Transform(oSelector).Method As IMsLinearRegressionTransform;
ARMA := oLinear.ARMA;
// Set 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 := 300;
// Set accuracy of solution
ARMA.Tolerance := 0.5;
// Specify that on calculating confidence limits do not consider
// that coefficients are found approximately
oLinear.CoefUncertaintyInSECalc := False;
// Set missing data treatment parameters
oLinear.MissingData.Method := MissingDataMethod.LinTrend;
// Set model calculation parameters
pCalc := oTransform.CreateCalculation;
pCalc.Period.IdentificationStartDate := DateTime.ComposeDay(2000, 1, 1);
pCalc.Period.IdentificationEndDate := DateTime.ComposeDay(2010, 12, 31);
pCalc.Period.ForecastStartDate := DateTime.ComposeDay(2011, 1, 1);
pCalc.Period.ForecastEndDate := DateTime.ComposeDay(2015, 12, 31);
coo := oTransform.CreateCoord(oOutputVariable);
oLinear.Identify(pCalc, coo);
// Get autoregression coefficients
CoefficientsAR := oLinear.ARMACoefficients(coo).CoefficientsAR;
Debug.WriteLine("Autoregression coefficients");
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 := oLinear.ARMACoefficients(coo).CoefficientsMA;
Debug.WriteLine("Moving average coefficients");
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]);
// Save changes in model
(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 options 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.
See also: