IMsCensus1Transform.CenterMovingAverage

Syntax

CenterMovingAverage: Boolean;

Description

The CenterMovingAverage property determines whether to center moving average.

Comments

Available values:

Example

Executing the example requires that the repository contains a modeling container with the MODEL_SPACE identifier containing a model with the MODEL_CENSUS1 identifier and a variable with the OUTPUT_VAR_CENSUS identifier. The variable must contain quarterly data.

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

Sub UserProc;
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    Model: IMsModel;
    Transform: IMsFormulaTransform;
    Vars: IMsFormulaTransformVariables;
    OutputStub: IVariableStub;
    OutputVar: IMsFormulaTransformVariable;
    Coord: IMsFormulaTransformCoord;
    Slice: IMsFormulaTransformSlice;
    Selector: IMsFormulaTransformSelector;
    Formula: IMsFormula;
    Census1: IMsCensus1Transform;
    Calc: IMsMethodCalculation;
    CPeriod, TPeriod: IMsModelPeriod;
    Data: Array 
Of Double;
Begin
mb := MetabaseClass.Active;
    
// Get modelling container
    MsObj := mb.ItemById("MODEL_SPACE");
    
// Get model
    Model := mb.ItemByIdNamespace("MODEL_CENSUS1", MsObj.Key).Edit As IMsModel;
    
// Get model parameters
    Transform := Model.Transform;
    
// Set output variable
    Vars := Transform.Outputs;
    Vars.Clear;
    OutputStub := mb.ItemByIdNamespace(
"OUTPUT_VAR_CENSUS", MsObj.Key).Edit As IVariableStub;
    OutputVar := Vars.Add(OutputStub);
    
// Get model calculation method parameters
    Coord := Transform.CreateCoord(OutputVar);
    Slice := OutputVar.Slices.Add(
Null);
    Selector := Transform.CreateSelector;
    Selector.Slice := Slice;
    Formula := Transform.Transform(Selector);
    
// Set calendar calculation frequency
    Formula.Level := DimCalendarLevel.Quarter;
    
// Set model calculation method
    Formula.Kind := MsFormulaKind.Census1;
    
// Get parameters of Census1 method calculation
    Census1 := Formula.Method As IMsCensus1Transform;
    
// Set seasonality type
    Census1.Seasonality := SeasonalityType.Additive;
    
// Center moving average
    Census1.CenterMovingAverage := True;
    
// Set parameters of missing data treatment
    Census1.MissingData.Method := MissingDataMethod.LinTrend;
    Census1.OutputType := MsCensus1OutputType.RD;
    
// Save changes
    (Model As IMetabaseObject).Save;
    
// Set calculation period parameters
    Calc := Transform.CreateCalculation;
    CPeriod := Calc.Period;
    TPeriod := model.Transform.Period;
    CPeriod.IdentificationStartDate := TPeriod.IdentificationStartDate;
    CPeriod.IdentificationEndDate := TPeriod.IdentificationEndDate;
    CPeriod.ForecastStartDate := TPeriod.ForecastStartDate;
    CPeriod.ForecastEndDate := TPeriod.ForecastEndDate;
    
// Perform calculation
    Census1.Execute(Calc, Coord);
    
// Display calculation results
    Data := Census1.Explained.Serie(Calc);
    Debug.WriteLine(
"Modeled data");
    Print(Data); Debug.WriteLine(
"");
    Data := Census1.MovingAverage;
    Debug.WriteLine(
"Smoothed series");
    Print(Data); Debug.WriteLine(
"");
    Data := Census1.RatioDifferences;
    Debug.WriteLine(
"Difference");
    Print(Data); Debug.WriteLine(
"");
    Data := Census1.Seasonal;
    Debug.WriteLine(
"Seasonal component");
    Print(Data); Debug.WriteLine(
"");
    Data := Census1.SeasonalAdjustment;
    Debug.WriteLine(
"Seasonal adjustment");
    Print(Data); Debug.WriteLine(
"");
    Data := Census1.TrendCycle;
    Debug.WriteLine(
"Trend cycle component");
    Print(Data); Debug.WriteLine(
"");
    Data := Census1.Irregula;
    Debug.WriteLine(
"Irregular component");
    Print(Data); Debug.WriteLine(
"");
End Sub UserProc;

// Data output procedure
Sub Print(Data: Array Of Double);
Var
    i: Integer;
Begin
    Debug.Indent;
    
For i := 0 To Data.Length - 1 Do
        Debug.WriteLine(i.ToString + 
" " + Data[i].ToString);
    
End For;
    Debug.Unindent;
End Sub Print;

After executing the example the MODEL_SPACE model is set up on calculation of the Census1 method, the model is calculated, the results are displayed in the console window.

See also:

IMsCensus1Transform