IModelling.Ecm

Fore Syntax

Ecm(Input: ITimeSeries;
    Period: IMsPeriod

    Method: ECMType;

    EndogenousVariableAROrder: Integer;

    ExogenousVariableAROrder: Integer;

    Casewise: MsCasewise;

    Explanatories: Array): Variant;

Fore.NET Syntax

Ecm(Context: Prognoz.Platform.Interop.Fore.ForeRuntimeContext;
    Input: Prognoz.Platform.Interop.Ms.ITimeSeries;
    Period: Prognoz.Platform.Interop.Ms.IMsPeriod;

    Method: Prognoz.Platform.Interop.Stat.ECMType;

    EndogenousVariableAROrder: integer;

    ExogenousVariableAROrder: integer;

    Casewise: Prognoz.Platform.Interop.Ms.MsCasewise;

    Explanatories: array of object): object;

Parameters

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

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.

Method. Type of error correction model.

EndogenousVariableAROrder. Autoregression order of endogenous (output) variable.

ExogenousVariableAROrder. Autoregression order of exogenous variables.

Casewise. Missing data treatment method.

Explanatories. Exogenous (explanatory) variables. They are specified via comma. Remember, that the number of exogenous variables (m) must satisfy to inequality: 0 < m < n-1 for model with constant and 0 < m < n for model without constant in cointegral equation, where n is the number of observations in the output variable.

Description

The Ecm method transforms variable by  error correction model.

Comments

Use this method only in series calculation mode.

Fore Example

Executing the example requires that the repository contains a modeling container with the MS identifier. This container includes a model with the MODEL_D identifier that is calculated by the method of determinate equation and contains several factors.

Add links to the Metabase, Ms system assemblies.

Sub ProcEcm;
Var
    Mb: IMetabase;
    ModelSpace, ModelObj: IMetabaseObject;
    Transf: IMsFormulaTransform;
    Formula: IMsFormula;
    Model: IMsModel;
    Determ: IMsDeterministicTransform;
    TransVar: IMsFormulaTransformVariable;
    Slice: IMsFormulaTransformSlice;
    TermInfo: IMsFormulaTermInfo;
    Inp_1, Inp_2: String;
    Expr: IExpression;
Begin
    Mb := MetabaseClass.Active;
    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.Pointwise;
    Inp_1 := TermInfo.TermInnerText;
    TransVar := Transf.Inputs.Item(
1);
    Slice := TransVar.Slices.Item(
0);
    TermInfo := Transf.CreateTermInfo;
    TermInfo.Slice := Slice;
    TermInfo.Type := MsFormulaTermType.Pointwise;
    Inp_2 := TermInfo.TermInnerText;
    Expr := Determ.Expression;
    Expr.References := 
"Ms;Stat";
    Expr.AsString := 
"Ecm(" + Inp_1 + ",SetPeriod(" +
        """" + "01.01.2000" + """" + "," + """" + "01.01.2015" + """" +
        "), ECMType.NoTrendNoIntercept, 1, 0, MsCasewise.Yes, "
 + Inp_2 + ")";
    
If Expr.Valid
        
Then ModelObj.Save;
        
Else Debug.WriteLine("The model is not saved: error in formula");
    
End If;
End Sub ProcEcm;

After executing the example the model transforms the first input variable using the error correction model. The calculation is applied at the period of 2000-2015 by missing data treatment by the Casewise method.

Fore.NET Example

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;
    Inp_1, Inp_2: String;
    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;
    Inp_1 := TermInfo.TermInnerText;
    TransVar := Transf.Inputs.Item[1];
    Slice := TransVar.Slices.Item[0];
    TermInfo := Transf.CreateTermInfo();
    TermInfo.Slice := Slice;
    TermInfo.Type := MsFormulaTermType.mfttPointwise;
    Inp_2 := TermInfo.TermInnerText;
    Expr := Determ.Expression;
    Expr.References := "Ms;Stat";
    Expr.AsString := "Ecm(" + Inp_1 + ",SetPeriod(" +
        """" + "01.01.2000" + """" + "," + """" + "01.01.2015" + """" +
        "), ECMType.NoTrendNoIntercept, 1, 0, MsCasewise.Yes, "
 + Inp_2 + ")";
    If Expr.Valid
        Then ModelObj.Save();
        Else System.Diagnostics.Debug.WriteLine("Model is not saved: error in formula");
    End If;
End Sub;

Example of Use in Expressions

Expression 1:

Ecm({Brazil|BCA[t]},SetPeriod("01.01.2002","01.01.2016"),ECMType.NoTrendIntercept,1,0, MsCasewise.Yes,{Afghanistan|BCA},{Canada|BCA})

Result: for the Brazil|BCA series the error correction model is calculated by the following parameters: model without trend in autoregression and with constant in cointegration level, the autoregression order in endogenous variable is 1, the order of autoregression of exogenous variables is 0, exogenous (explanatory) variables are Afghanistan|BCA and Canada|BCA factors. The calculation is executed at the period of 2002-2016 by the Casewise missing data treatment method.

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:

Ecm(X1,ECMType.TrendIntercept,0,1, MsCasewise.Yes,X2,X3)

Result: for the X1 factor the error correction model is calculated by the following parameters: model with linear trend in autoregression and constant in cointegration equation, the order of autoregression of endogenous variable is 0, order of autoregression of exogenous variables is 1, exogenous (explanatory) variables are the X2 and the X3 factors. Calculation is executed for the whole period using the Casewise missing data treatment method.

Use: it can be used in model variable-based formulas of modeling container.

See also:

Imodelling | Method of Calculation of  error correction model | Time Series Database: Calculator, Error Correction Model | Modeling Container:Error Correction Model, Editing Regressor or Formula