IMsLinearRegressionTransform.ARMA

Fore Syntax

ARMA: ISlARMA;

Fore.NET Syntax

ARMA: Prognoz.Platform.Interop.Stat.ISlARMA;

Description

The ARMA property returns autoregression and moving average parameters.

Comments

If autoregression or moving average order is set for a model, upper and lower dynamic confidence limits of forecasting series are calculated.

Fore Example

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[
1Of 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(0As 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(
200011);
    pCalc.Period.IdentificationEndDate := DateTime.ComposeDay(
20101231);
    pCalc.Period.ForecastStartDate := DateTime.ComposeDay(
201111);
    pCalc.Period.ForecastEndDate := DateTime.ComposeDay(
20151231);
    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 statistics: ");
    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 statistics: ");
    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 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.

Fore.NET Example

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;
    oLinear: IMsLinearRegressionTransform;
    ARMA: ISlARMA;
    pCalc: IMsMethodCalculation;
    coo: IMsFormulaTransformCoord;
    AR, MR: Array[1Of Integer;
    CoefficientsAR, CoefficientsMA: ICoefficients;
    Estimate, Probability, StandardError, TStatistic: System.Array;
Begin
    mb := Params.Metabase;
    // 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 variable
    oOutputVariable := oTransform.Outputs.Item[0As IMsFormulaTransformVariable;
    oSelector.Slice := oOutputVariable.Slices.Item[0];
    // Set up linear regression calculation
    oLinear := oTransform.Transform[oSelector].Method As IMsLinearRegressionTransform;
    ARMA := oLinear.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 := 300;
    // Set accuracy of solution
    ARMA.Tolerance := 0.5;
    // Specify that on calculating confidence limits we do not consider
    // that coefficients are found approximately
    oLinear.CoefUncertaintyInSECalc := False;
    // Set the parameters of missing data treatment
    oLinear.MissingData.Method := MissingDataMethod.mdmLinTrend;
    // Set model calculation parameters
    pCalc := oTransform.CreateCalculation();
    pCalc.Period.IdentificationStartDate := DateTime.Parse("2000.1.1");
    pCalc.Period.IdentificationEndDate := DateTime.Parse("2010.12.31");
    pCalc.Period.ForecastStartDate := DateTime.Parse("2011.1.1");
    pCalc.Period.ForecastEndDate := DateTime.Parse("2015.12.31");
    coo := oTransform.CreateCoord(oOutputVariable);
    oLinear.Identify(pCalc, coo);
    // Get autoregression coefficients
    CoefficientsAR := oLinear.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 := oLinear.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]);
    // Save changes in the model
    (oModel As IMetabaseObject).Save();
End Sub;

See also:

IMsLinearRegressionTransform