IModelling.Census1

Syntax

Census1(Input: ITimeSeries;
    Period: IMsPeriod;
    OutputSeries: MsOutputCensus1SeriesType;
    SeasonalEffect: SeasonalityType;
    [SeasonalPeriod: Integer = 12];
    [Casewise: MsCasewise = 0]): Variant;

Census1(Input: Prognoz.Platform.Interop.Ms.ITimeSeries;
    Period: Prognoz.Platform.Interop.Ms.IMsPeriod;
    OutputSeries: Prognoz.Platform.Interop.Ms.MsOutputCensus1SeriesType;
    SeasonalEffect: Prognoz.Platform.Interop.Stat.SeasonalityType;
    SeasonalPeriod: Integer;
    Casewise: Prognoz.Platform.Interop.Ms.MsCasewise
    Context: Prognoz.Platform.Interop.Fore.ForeRuntimeContext): Object;

Parameters

Input. Output 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.

SeasonalPeriod. Duration of seasonal period.

Casewise. Missing data treatment method.

Context. Execution context. The parameter is used only in Fore.NET.

Description

The Census1 method calculates seasonal component according to the specified parameters.

Example

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.

Add links to the Metabase, Ms, Stat system assemblies. For the Fore.NET example also add a link to the ForeSystem system assembly.

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
    
// 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 variable transfer for calculation
    TermInfo.Type := MsFormulaTermType.Pointwise;
    
// Get expression of model calculation
    Expr := Determ.Expression;
    Expr.References := 
"Ms;Stat";
    
// Set expression of model calculation
    Expr.AsString := "Census1(" + TermInfo.TermInnerText + ", SetPeriod(" +
        
"""" + "01.01.2000" + """" + "," + """" + "01.01.2015" + """" +
        
"), MsOutputCensus1SeriesType.MovingAverage, SeasonalityType.Additive)";
    
// Check that expression is correct
    If Expr.Valid Then
        
// If expression is set correctly, save model
        ModelObj.Save;
    
Else
        
// If expression is incorrect, display message in the console window
        Debug.WriteLine("Model is not saved: error in formula");
    
End If;
End Sub UserProc;

Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Stat;

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 variable transfer for calculation
    TermInfo.Type := MsFormulaTermType.mfttPointwise;
    
// Get expression of model calculation
    Expr := Determ.Expression;
    Expr.References := 
"Ms;Stat";
    
// Set expression of model calculation
    Expr.AsString := "Census1(" + TermInfo.TermInnerText + ", SetPeriod(" +
        
"""" + "01.01.2000" + """" + "," + """" + "01.01.2015" + """" +
        
"), MsOutputCensus1SeriesType.MovingAverage, SeasonalityType.Additive)";
    
// Check that expression is correct
    If Expr.Valid Then
        
// If expression is set correctly, save model
        ModelObj.Save();
    
Else
        
// If expression is incorrect, display message in the console window
        System.Diagnostics.Debug.WriteLine("Model is not saved: error in formula");
    
End If;
End Sub;

After executing the example the model calculates values on the basis of the first input variable by the Census1 method for the period from 2000 to 2015. A smoothed series of the input variable is loaded to the output variable.

See also:

IModelling | The Centus1 Method