IMsCensus2Transform.SigmaLower

Syntax

SigmaLower: Double;

Description

The SigmaLower property determines a lower sigma limit.

Comments

Most of real time series include outliers. They can distort seasonality and trend estimations. The X11 method enables the user to reduce outliers influence by excluding the values that lie outside the specified range or by converting these values. Range width is set by the lower and the upper sigma limits. The upper sigma limit is determined by the IMsCensus2Transform.SigmaUpper property.

The X11 method is supported only in Windows.

Example

Executing the example requires that the repository contains a modeling container with the MS identifier and a time series database with the TSDB identifier. The modeling container should include a model with the MODEL_CENSUS2 identifier.

Add links to the Cubes, Dimensions, Metabase, Ms, Stat system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    ModelCont, RubrDescr: IMetabaseObjectDescriptor;
    Model: IMsModel;
    Transform: IMsFormulaTransform;
    TransformVarables: IMsFormulaTransformVariables;
    Stub: IVariableStub;
    TransVar: IMsFormulaTransformVariable;
    Tree: IMsFormulaTransformSlicesTree;
    Slice: IMsFormulaTransformSlice;
    Selector: IMsFormulaTransformSelector;
    Formula: IMsFormula;
    CENS: IMsCensus2Transform;
    Expl: IMsFormulaTerm;
    Av, W: Array Of Double;
    Info: IMsFormulaTermInfo;
Begin
    // Get current repository
    MB := MetabaseClass.Active;
    // Get modeling container
    ModelCont := MB.ItemById("MS");
    // Get model
    Model := MB.ItemByIdNamespace("MODEL_CENSUS2", ModelCont.Key).Edit As IMsModel;
    // Get object for setting up model parameters
    Transform := Model.Transform;
    // Get object work working with output variable
    TransformVarables := Transform.Outputs;
    // Get time series database (TSDB)
    RubrDescr := Mb.ItemById("TSDB");
    // Cast obtained TSDB to abstract data source
    Stub := RubrDescr.Bind As IVariableStub;
    // Use TSDB as a data source of output variable
    TransVar := TransformVarables.Add(Stub);
    // Set output variable slice
    Tree := TransVar.SlicesTree(TransVar);
    Slice := Tree.CreateSlice(1);
    // Get model settings for output variable slice
    Selector := Transform.CreateSelector;
    Selector.Slice := Slice;
    Formula := Transform.Transform(Selector);
    // Set calendar frequency of calculation
    Formula.Level := DimCalendarLevel.Month;
    // Specify calculation method: X11
    Formula.Kind := MsFormulaKind.Census2;
    // Get method parameters
    CENS := Formula.Method As IMsCensus2Transform;
    // Get object for working with loaded variables
    TransformVarables := Transform.Series;
    // Clear collection of loaded variables
    TransformVarables.Clear;
    // Specify the series, to which data will be loaded after prior adjustment
    TransVar := TransformVarables.Add(Stub);
    Tree := TransVar.SlicesTree(TransVar);
    Slice := Tree.CreateSlice(2);
    Info := Transform.CreateTermInfo;
    Info.Slice := Slice;
    CENS.B1Term := Info;
    // Specify the series, to which seasonal component of source series will be loaded
    TransVar := TransformVarables.Add(Stub);
    Tree := TransVar.SlicesTree(TransVar);
    Slice := Tree.CreateSlice(3);
    Info := Transform.CreateTermInfo;
    Info.Slice := Slice;
    CENS.D10Term := Info;
    // Specify the series, to which seasonal adjustment will be loaded
    TransVar := TransformVarables.Add(Stub);
    Tree := TransVar.SlicesTree(TransVar);
    Slice := Tree.CreateSlice(4);
    Info := Transform.CreateTermInfo;
    Info.Slice := Slice;
    CENS.D11Term := Info;
    // Specify the series, to which series trend-cycle component will be loaded
    TransVar := TransformVarables.Add(Stub);
    Tree := TransVar.SlicesTree(TransVar);
    Slice := Tree.CreateSlice(5);
    Info := Transform.CreateTermInfo;
    Info.Slice := Slice;
    CENS.D12Term := Info;
    // Specify the series, to which series irregular component will be loaded
    TransVar := TransformVarables.Add(Stub);
    Tree := TransVar.SlicesTree(TransVar);
    Slice := Tree.CreateSlice(6);
    Info := Transform.CreateTermInfo;
    Info.Slice := Slice;
    CENS.D13Term := Info;
    // Set weight coefficients of days of week
    W := New Double[7];
    W[0] := 1.17;
    W[1] := 1.00;
    W[2] := 1.12;
    W[3] := 1.10;
    W[4] := 0.95;
    W[5] := 0.98;
    W[6] := 1.07;
    CENS.DailyWeights := W;
    // Display output series name
    Expl := CENS.Explained;
    Debug.WriteLine(Expl.TermToText);
    // Set missing data treatment method
    CENS.MissingData.Method := MissingDataMethod.PrevValue;
    // Set moving average
    Av := New Double[12];
    Av[0] := 0.02; Av[4] := 0.12;Av[8] := 0.01;
    Av[1] := 0.1; Av[5] := 0.11; Av[9] := 0.7;
    Av[2] := 0.2; Av[6] := 0.3; Av[10] := 0.4;
    Av[3] := 0.5; Av[7] := 0.45; Av[11] := 0.3;
    CENS.MovingAverage := Av;
    // Set seasonality type
    CENS.Seasonality := SeasonalityType.Multiplicative;
    // Set lower and upper sigma limits
    CENS.SigmaLower := 1.5;
    CENS.SigmaUpper := 2.5;
    // Set working day adjustment type
    CENS.TraidingDaysAdjustment := TraidingDaysAdj.Auto;
    // Set holiday adjustment
    CENS.HolidayAdj := Census2HolidayAdjType.C2hatEaster;
    // Use sliding spans
    CENS.SlidingSpans := True;
    // Save changes
    (Model As IMetabaseObject).Save;
End Sub UserProc;

After executing the example new parameters for X11 method calculation are set for the MODEL_CENSUS2 model, the input and output variables are determined. The model is calculated, data is loaded to corresponding variables. The console displays output series name, for example:

{Population, mln. people|Chicago[t]}

See also:

IMsCensus2Transform