IModelling.Tsls

Syntax

Tsls(Input: ITimeSeries;
     Period: IMsPeriod;
     ConstantValue: Variant;
     AROrder: String;
     MAOrder: String;
     Casewise: MsCasewise;
     Explanatories: Array): Variant;

Parameters

Input. Output variable.

Period. Period, at which the method is calculated.

ConstantValue. Constant used in calculations.

AROrder. Autoregression order.

MAOrder. Moving average order.

Casewise. Missing data treatment method.

Explanatories. Exogenous and instrumental variables.

Description

The Tsls method models a variable with the help of linear regression (estimation by method of instrumental variables).

Comments

Use this method only in series calculation mode.

Features of setting parameters:

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 determinate equation method and contains more than one input factor.

Add links to the Metabase and 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;
    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";
    Expr.AsString := "Tsls(" + Inp_1 + ", SetPeriod(" +
        """" + "01.01.2000" + """" + "," + """" + "01.01.2015" + """" +
        "), Estimate, """ + "1 - 3" + """, """ + "1; 3" +
        """, MsCasewise.Yes, " + Inp_2 +
        ", Null, " + Inp_2 + ")";
    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 will model the first input variable using linear regression (instrumental variables estimation) for the period from 2000 to 2015. Calculation is executed using the Casewise missing data treatment method.

Example of Use in Expressions

Expression 1:

Tsls({Brazil|BCA[t]},SetPeriod("01.01.2000","01.01.2015"),Estimate,"","",MsCasewise.Yes,{China|BCA},Null,{Japan|BCA})

Result: the Brazil|BCA series is modeled by the linear regression method (instrumental variables estimation) by the following parameters: constant is estimated by the IModelling.Estimate method, autoregression and moving average orders are not set, the China|BCA factor is used as the exogenous variable, the Japan|BCA factor is used as the instrumental variable, calculation is executed at the period from 2000 to 2015 using the Casewise missing data treatment method.

Use: it can be used in formulas of cross functional expression editor in any platform tool where it is available.

Expression 2:

Tsls(X1,None,"1","2;backcast.No",MsCasewise.Yes,X4,Null,X2, X3)

Result: the X1 factor is modeled by the linear regression method (instrumental variables estimation) by the following parameters: constant is not set, the autoregression order is 1, the moving average order is 2, backcasting is not used for moving average coefficients estimation, the X4 factor is the exogenous variable, the X2 and X3 factors are instrumental variables, calculation is executed at the entire period using the Casewise missing data treatment method.

Use: it can be used in model formulas of modeling container based on variables.

See also:

IModelling | Instrumental variables method | Time Series Database: Calculator Modeling Container: The Linear Regression (Instrumental Variables Estimation)Model, Editing Regressor or Formula