IModelling.ArimaR

Fore Syntax

ArimaR(Input: ITimeSeries;
       Period: IMsPeriod;
       NotSeasonalIAR: Integer;
       NotSeasonalIMA: Integer;
       NotSeasonalDIFF: Integer;
       ConstantValue: Variant;
       [SeasonalAR: Integer = 0;]
       [SeasonalMA: Integer = 0;]
       [SeasonalDiff: Integer = 1;]
       [SeasonalPeriod: Integer = 0;]
       [MaxIteration: Integer = 500;]
       [Precision: Double = 0.0001;]
       [Casewise: MsCasewise = 0]): Variant;

Fore.NET Syntax

ArimaR(Input: Prognoz.Platform.Interop.Ms.ITimeSeries;

       Period: Prognoz.Platform.Interop.Ms.IMsPeriod;

       NotSeasonalIAR: integer;

       NotSeasonalIMA: integer;

       NotSeasonalDIFF: integer;

       ConstantValue: object;

       SeasonalAR: integer;

       SeasonalMA: integer;

       SeasonalDiff: integer;

       SeasonalPeriod: integer;

       MaxIteration: integer;

       Precision: double;

       Casewise: Prognoz.Platform.Interop.Ms.MsCasewise;
       Context: Prognoz.Platform.Interop.Fore.ForeRuntimeContext): object;

Parameters

Input. Output variable.

Period. Period, at which the method is calculated. If the parameter is set to Null, the method is calculated at the entire time period.

NotSeasonalIAR. Non-seasonal autoregression order.

NotSeasonalIMA. Non-seasonal moving average order.

NotSeasonalDIFF. Non-seasonal difference order.

ConstantValue. Constant used in calculations.

SeasonalAR. Seasonal regression order.

SeasonalMA. Seasonal moving average order.

SeasonalDiff. Seasonal difference order.

SeasonalPeriod. Duration of seasonal period.

MaxIteration. Maximum number of iterations, in which the optimal decision must be found.

Precision. Calculation accuracy.

Casewise. Missing data treatment method.

Context. Context. The parameter is used only in Fore.NET.

Description

The ArimaR method models variable values with the ARIMA method using the R package.

Comments

Integration with R must be set up in the repository to use this method. For details about integration setup see the How to Set Up Integration with R? section.

ConstantValue. The value of the constant can be determined by the user or estimated automatically. Use the IModelling.Estimate method to estimate values automatically. If the model must be calculated without constant, use the IModelling.None method.

Fore Example

Executing the example requires that the repository contains a modeling container with the MS identifier. A model with the MODEL_D identifier calculated by the method of determinate equation and containing at least one input variable must be available in this container.

Integration with R must be set up in the repository. For details about integration setup see the How to Set Up Integration with R? section.

Add links to the Metabase, Ms system assemblies.

Sub UserArimaR;
Var
    Mb: IMetabase;
    ModelSpace, ModelObj: IMetabaseObject;
    Transf: IMsFormulaTransform;
    Formula: IMsFormula;
    Model: IMsModel;
    Determ: IMsDeterministicTransform;
    TransVar: IMsFormulaTransformVariable;
    Slice: IMsFormulaTransformSlice;
    TermInfo: IMsFormulaTermInfo;
    Expr: IExpression;
Begin
    // Get repository
    Mb := MetabaseClass.Active;
    // Get modeling container
    ModelSpace := Mb.ItemById("MS").Bind;
    // Get model
    ModelObj := Mb.ItemByIdNamespace("MODEL_D", ModelSpace.Key).Edit;
    Model := ModelObj As IMsModel;
    // Get model calculation parameters
    Transf := Model.Transform;
    Formula := Transf.FormulaItem(0);
    Determ := Formula.Method As IMsDeterministicTransform;
    // Get the first input variable
    TransVar := Transf.Inputs.Item(0);
    Slice := TransVar.Slices.Item(0);
    TermInfo := Transf.CreateTermInfo;
    TermInfo.Slice := Slice;
    // Set mode of passing variable into calculation
    TermInfo.Type := MsFormulaTermType.Pointwise;
    // Get model calculation expression
    Expr := Determ.Expression;
    Expr.References := "Ms";
    // Set model calculation expression
    Expr.AsString := "ArimaR(" + TermInfo.TermInnerText + ", SetPeriod(" +
        """" + "01.01.2000" + """" + "," + """" + "01.01.2015" + """" +
        "), 0, 1, 0, Estimate, 1, 1, 0, 1, 600, 0.001, MsCasewise.Yes)";
    // Check if the expression is correct
    If Expr.Valid
        // If the expression is set correctly, save the model
        Then ModelObj.Save;
        // If the expression is incorrect, display a message to the console window 
        Else Debug.WriteLine("Model is not saved: error in the formula");
    End If;
End Sub UserArimaR;

After executing the example the model is calculated the value of first input variable by ARIMA method. The following parameters will be defined for the method: calculation period, autoregression and moving average orders, the constant will be auto estimated, and the Casewise method will be used for missing data treatment. Calculation is executed using the R package.

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.ForeSystem;

Public Shared Sub Main(Params: StartParams);
Var
    Mb: IMetabase;
    ModelSpace, ModelObj: IMetabaseObject;
    Transf: IMsFormulaTransform;
    Formula: IMsFormula;
    Model: IMsModel;
    Determ: IMsDeterministicTransform;
    TransVar: IMsFormulaTransformVariable;
    Slice: IMsFormulaTransformSlice;
    TermInfo: IMsFormulaTermInfo;
    Expr: IExpression;
Begin
    // Get repository
    Mb := Params.Metabase;
    // Get modeling container
    ModelSpace := Mb.ItemById["MS"].Bind();
    // Get model
    ModelObj := Mb.ItemByIdNamespace["MODEL_D", ModelSpace.Key].Edit();
    Model := ModelObj As IMsModel;
    // Get model calculation parameters
    Transf := Model.Transform;
    Formula := Transf.FormulaItem[0];
    Determ := Formula.Method As IMsDeterministicTransform;
    // Get the first input variable
    TransVar := Transf.Inputs.Item[0];
    Slice := TransVar.Slices.Item[0];
    TermInfo := Transf.CreateTermInfo();
    TermInfo.Slice := Slice;
    // Set mode of passing variable into calculation
    TermInfo.Type := MsFormulaTermType.mfttPointwise;
    // Get model calculation expression
    Expr := Determ.Expression;
    Expr.References := "Ms";
    // Set model calculation expression
    Expr.AsString := "ArimaR(" + TermInfo.TermInnerText + ", SetPeriod(" +
        """" + "01.01.2000" + """" + "," + """" + "01.01.2015" + """" +
        "), 0, 1, 0, Estimate, 1, 1, 0, 1, 600, 0.001, MsCasewise.Yes)";
    // Check if the expression is correct
    If Expr.Valid
        // If the expression is set correctly, save the model
        Then ModelObj.Save();
        // If the expression is incorrect, display a message to the console window 
        Else System.Diagnostics.Debug.WriteLine("Model is not saved: error in the formula");
    End If;
End Sub

Example of Use in Expressions

Expression 1:

ArimaR({Chicago - population[t]}, SetPeriod(2000, 2015), 0, 1, 1, Estimate)

Result: the ARIMA method is calculated for the Chicago - population time series with the following parameters: calculation period - 2000-2015, order of non-seasonal autoregression - 0, order of non-seasonal moving average - 1, order of non-seasonal difference - 1, constant value is auto estimated with the IModelling.Estimate method. Calculation is executed using the R package.

Use: it can be used in formulas of calculated series of time series database and in formulas of attribute-based models of modeling container.

Expression 2:

ArimaR(X1,Null, 0, 0, 1, 2.7, 0, 0, 1, 0, 500, 0.0001, MsCasewise.Yes)

Result: the ARIMA method is calculated for the X1 factor with the following parameters: orders of non-seasonal autoregression and non-seasonal moving average are not defined, order of non-seasonal difference - 1, constant value is equal to 2,7, the Casewise method is used for missing data treatment. Calculation is executed using the R package.

Use: it can be used in model variable-based formulas of modeling container.

See also:

IModelling | The ARIMA Method | Time Series Database: Calculator, ARIMA | Modeling Container: The ARIMA Model, Editing Regressor or Formula