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;
ExpSmoothR(Input: Prognoz.Platform.Interop.Ms.ITimeSeries;
Period: Prognoz.Platform.Interop.Ms.IMsPeriod;
SeasonalEffect: Prognoz.Platform.Interop.Stat.SeasonalityType;
SeasonalPeriod: integer;
Trend: Prognoz.Platform.Interop.Stat.TrendType;
Alpha: object;
Delta: object;
Gamma: object;
Phi: object;
Casewise: Prognoz.Platform.Interop.Ms.MsCasewise;
GridStep: double;
Context: Prognoz.Platform.Interop.Fore.ForeRuntimeContext): object;
Input. 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.
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.
Context. Context. The parameter is used only in Fore.NET.
The ExpSmoothR method transforms variable data with the exponential smoothing method using the R package.
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.
The SeasonalPeriod parameter value must be greater or equal to four. The parameter is considered if the additive or multiplicative seasonal model is used.
Values of the Alpha, Delta, Gamma, Phi coefficients can be set by user or automatically. Use the IModelling.Estimate method to estimate values automatically.
The value of the Delta parameter is taken into account if the additive or multiplicative seasonal model is used.
The value of the Gamma parameter is taken into account if the additive or exponential growth model is used.
The value of the Phi parameter is taken into account if the fading growth model is used.
Casewise. Optional parameter. Missing data treatment is not used by default.
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 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 transforms the first input variable using the exponential smoothing method. Calculation is executed by the R package.
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;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 System.Diagnostics.Debug.WriteLine("Model is not saved: error in the formula");
End If;
End Sub;
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 applied to 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 calculated series of time series database and model formulas of modeling container that is a child of the time series database.
Expression 2:
ExpSmoothR(X1, Null, SeasonalityType.Additive, 4,TrendType.Linear, 0.2, 0, 0.2, 0, MsCasewise.No, 0.2)
Result: exponential smoothing with the following parameters is executed for the X1 factor: calculation is executed at the entire time period, 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.2, missing data treatment is not used, gird step value is 0.2. 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