IModelling.ExpSmoothR

Syntax

ExpSmoothR(Input: ITimeSeries;

           Period: IMsPeriod;

           SeasonalEffect: SeasonalityType;

           SeasonalPeriod: Integer;

           Trend: TrendType;

           Alpha: Variant;

           Delta: Variant;

           Gamma: Variant;

           Phi: Variant;

           [Casewise: MsCasewise = 0;]

           [GridStep: Double = 0.1]): Variant;

Parameters

Input. Variable.

Period. Period, at which the method is calculated

SeasonalEffect. Seasonal model.

SeasonalPeriod. Length of seasonal period.

Trend. Growth model.

Alpha. Alpha coefficient.

Delta. Delta coefficient.

Gamma. Gamma coefficient.

Phi. Phi coefficient.

Casewise. Missing data treatment method.

GridStep. Grid step.

Description

The ExpSmoothR method transforms variable data with the exponential smoothing method using the R package.

Comments

Integration with R must be set up in the repository to use this method. To set up integration, see the How to Set Up Integration with R? section.

Features of setting parameters:

NOTE. Values of the Alpha, Delta, Gamma, Phi coefficients can be set by the user or estimated automatically. To estimate values automatically, use the IModelling.Estimate method.

Example

Executing the example requires that the repository contains a modeling container with the MS identifier. This container includes a model with the MODEL_D identifier that is calculated using the determinate equation method and contains at least one input variable.

Integration with R must be set up in the repository. To set up integration, see the How to Set Up Integration with R? section.

Add links to the Metabase and Ms system assemblies.

Sub UserExpSmoothR;
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;Stat";
    // Set model calculation expression
    Expr.AsString := "ExpSmoothR(" + TermInfo.TermInnerText + ", SetPeriod(" +
        """" + "01.01.2000" + """" + "," + """" + "01.01.2015" + """" +
        "), SeasonalityType.Additive, 4, TrendType.Damped, " +
        "0.15, Estimate, Estimate, Estimate, MsCasewise.Yes, 0.2)";
    // 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 UserExpSmoothR;

After executing the example the model will transform the first input variable using the exponential smoothing method. Calculation will be executed using the R package.

Example of Use in Expressions

Expression 1:

ExpSmoothR({Chicago - population[t]}, SetPeriod("2000", "2015"), SeasonalityType.Additive , 4, TrendType.Linear, 0.1, 0, 0.1, 0)

Result: exponential smoothing with the following parameters is executed for the Chicago - population time series: method calculation period - 2000-2015, additive seasonal model is used, length of seasonal period is four, values of the Delta and Phi coefficients are equal to 0, values of the Alpha and Gamma coefficients are equal to 0.1. Calculation is executed using the R package.

Use: it can be used in formulas of cross functional expression editor in any platform tool where it is available.

Expression 2:

ExpSmoothR(X1, Null, SeasonalityType.Additive, 4,TrendType.Linear, 0.2, 0, 0.2, 0, MsCasewise.No, 0.2)

Result: exponential smoothing is executed for the X1 factor by the following parameters: exponential smoothing is executed at the entire time period, additive seasonal model is used, length of seasonal period is 4, values of the Delta and Phi coefficients are 0, values of the Alfa and Gamma coefficients are 0.2, grid step is 0.3. Calculation is executed using the R package.

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

See also:

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