X11(Input: ITimeSeries;
Period: IMsPeriod
OutputSeries: MsOutputSeriesType;
SeasonalEffect: SeasonalityType;
[TradingDaysAdjustment: MsTradingDaysAdjustment = 0;]
[LowerSigma: Double = 1.5;]
[UpperSigma: Double = 2.5;]
[MovingAverage: String = "";]
[WeightCoefficients: String = "";]
[HolidayAdjustment: MsHolidayAdjustment = 0;]
[SSAnalysis: Boolean = False]): Variant;
X11(Input: Prognoz.Platform.Interop.Ms.ITimeSeries;
Period: Prognoz.Platform.Interop.Ms.IMsPeriod;
OutputSeries: Prognoz.Platform.Interop.Ms.MsOutputSeriesType;
SeasonalEffect: Prognoz.Platform.Interop.Stat.SeasonalityType;
TradingDaysAdjustment: Prognoz.Platform.Interop.Ms.MsTradingDaysAdjustment;
LowerSigma: double;
UpperSigma: double;
MovingAverage: string;
WeightCoefficients: string;
HolidayAdjustment: Prognoz.Platform.Interop.Ms.MsHolidayAdjustment;
SSAnalysis: boolean;
Context: Prognoz.Platform.Interop.Fore.ForeRuntimeContext): object;
Input. 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.
OutputSeries. Series type that is loaded to the output variable.
SeasonalEffect. Seasonal model.
TradingDaysAdjustment. Working day adjustment.
LowerSigma. Lower sigma limit.
UpperSigma. Upper sigma limit.
MovingAverage. Moving average.
WeightCoefficients. Weight coefficients.
HolidayAdjustment. Holiday adjustment.
SSAnalysis. Indicates whether sliding spans are used in calculation.
Context. Context. The parameter is used only in Fore.NET.
X11 executes seasonal decomposition and seasonal adjustment.
The method returns correct results only during work with monthly or quarterly frequency.
TradingDaysAdjustment. Optional parameter, working day adjustment is not calculated by default.
LowerSigma. Optional parameter, the default value is 1.5.
UpperSigma. Optional parameter, the default value is 2.5.
MovingAverage, WeightCoefficients. Optional parameters, the default value is not set.
HolidayAdjustment. Optional parameter. Holiday adjustment is not executed by default.
SSAnalysis. Optional parameter, the default value is False (sliding spans are not used in calculation).
Executing the example requires that the repository contains a modeling container with the MS identifier. A model with the MODEL_D_Q identifier that is calculated by the method of determinate equation based on the quarterly data and contains at least one factor is present in this container.
Add links to the Metabase, Ms system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
ModelSpace, ModelObj: IMetabaseObject;
Transf: IMsFormulaTransform;
Formula: IMsFormula;
Model: IMsModel;
Determ: IMsDeterministicTransform;
TransVar: IMsFormulaTransformVariable;
Slice: IMsFormulaTransformSlice;
TermInfo: IMsFormulaTermInfo;
Expr: IExpression;
Begin
Mb := MetabaseClass.Active;
ModelSpace := Mb.ItemById("MS").Bind;
ModelObj := Mb.ItemByIdNamespace("MODEL_D_Q", ModelSpace.Key).Edit;
Model := ModelObj As IMsModel;
Transf := Model.Transform;
Formula := Transf.FormulaItem(0);
Determ := Formula.Method As IMsDeterministicTransform;
TransVar := Transf.Inputs.Item(0);
Slice := TransVar.Slices.Item(0);
TermInfo := Transf.CreateTermInfo;
TermInfo.Slice := Slice;
TermInfo.Type := MsFormulaTermType.Pointwise;
Expr := Determ.Expression;
Expr.References := "Ms;Stat";
Expr.AsString := "X11(" + TermInfo.TermInnerText + ",SetPeriod(" +
"""" + "01.01.2000" + """" + "," + """" + "01.01.2015" + """" +
"),MsOutputSeriesType.D10, SeasonalityType.Additive, " +
"MsTradingDaysAdjustment.No, 1.8, 2.1, """", """", MsHolidayAdjustment.None, False)";
If Expr.Valid Then
ModelObj.Save;
Else
Debug.WriteLine("Model is not saved: error in formula");
End If;
End Sub UserProc;
After executing the example the model executes seasonal decomposition and seasonal adjustment by the X11 method without the holidays adjustment and using of sliding spans for 2000 to 2015 years.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Ms;
…
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
Mb := Params.Metabase;
ModelSpace := Mb.ItemById["MS"].Bind();
ModelObj := Mb.ItemByIdNamespace["MODEL_D", ModelSpace.Key].Edit();
Model := ModelObj As IMsModel;
Transf := Model.Transform;
Formula := Transf.FormulaItem[0];
Determ := Formula.Method As IMsDeterministicTransform;
TransVar := Transf.Inputs.Item[0];
Slice := TransVar.Slices.Item[0];
TermInfo := Transf.CreateTermInfo();
TermInfo.Slice := Slice;
TermInfo.Type := MsFormulaTermType.mfttPointwise;
Expr := Determ.Expression;
Expr.References := "Ms;Stat";
Expr.AsString := "X11(" + TermInfo.TermInnerText + ",SetPeriod(" +
"""" + "01.01.2000" + """" + "," + """" + "01.01.2015" + """" +
"),MsOutputSeriesType.D10, SeasonalityType.Additive, " +
"MsTradingDaysAdjustment.No, 1.8, 2.1, """", """", MsHolidayAdjustment.None, False)";
If Expr.Valid Then
ModelObj.Save();
Else
System.Diagnostics.Debug.WriteLine("Model is not saved: error in the formula");
End If;
End Sub;
Expression 1:
x11({Brazil|BCA[t]}, SetPeriod("2000", "2015"), MsOutputSeriesType.D10, SeasonalityType.Additive, MsTradingDaysAdjustment.Auto)
Result: for the Brazil|BCA factor the seasonal decomposition and seasonal adjustment with automatic working day adjustment are executed for the period from 2000 to 2015.
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:
x11(X1, Null, MsOutputSeriesType.D10, SeasonalityType.Additive, MsTradingDaysAdjustment.No, 1.8, 2.1
, "", "", MsHolidayAdjustment.None, False)
Result: for the X1 factor seasonal decomposition and seasonal adjustment by the X11 method without the holidays adjustment and using of sliding spans is executed for the entire period.
Use: it can be used in model variable-based formulas of modeling container.
See also:
IModelling | The X11Method | Time Series Database: Calculator, Seasonal Adjustment Modeling Container: The X11Model, Editing Regressor or Formula