IMsFormulaTermInfo.Lag

Syntax

Lag: String;

Description

The Lag property determines the lag value for the term.

Comments

The lag indicates the shift of element index, which value is used during the calculation in this point. The property is set to 0 by default, the value of the current element is used.

Example

Executing the example requires that the repository contains a modeling container with the KONT_MODEL identifier. The container contains the VAR_1 variable that will be used as an output one, and the VAR_FACTOR variable used as a factor.

Add links to the Metabase and Ms system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Kont: IMetabaseObjectDescriptor;
    CrInf: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    Model: IMsModel;
    Trans: IMsFormulaTransform;
    VarTrans: IMsFormulaTransformVariable;
    Tree: IMsFormulaTransformSlicesTree;
    Slice: IMsFormulaTransformSlice;
    Selector: IMsFormulaTransformSelector;
    Formula: IMsFormula;
    NonLinear: IMsNonLinearRegressionTransform;
    Varr: IVariableStub;
    TransVar: IMsFormulaTransformVariable;
    TermX1: IMsFormulaTerm;
    TermX1Info: IMsFormulaTermInfo;
Begin
    MB := MetabaseClass.Active;
    Kont := Mb.ItemById("KONT_MODEL");
    //create a model
    CrInf := Mb.CreateCreateInfo;
    CrInf.ClassId := MetabaseObjectClass.KE_CLASS_MSMODEL;
    CrInf.Id := "New_NonLinReg";
    CrInf.Name := "New_NonLinReg";
    CrInf.Parent := Kont;
    MObj := Mb.CreateObject(CrInf).Edit;
    Model := MObj As IMsModel;
    Trans := Model.Transform;
    //add an output variable
    Varr := MB.ItemByIdNamespace("Var_1",Kont.Key).Bind As IVariableStub;
    Trans.Outputs.Add(Varr);
    VarTrans := Trans.Outputs.Item(0);
    Tree := VarTrans.SlicesTree(VarTrans);
    Slice := Tree.CreateSlice(1);
    Selector := Trans.CreateSelector;
    Selector.Slice := Slice;
    Formula := Trans.Transform(Selector);
    Formula.Kind := MsFormulaKind.NonLinearRegression;
    Formula.Level := DimCalendarLevel.Year;
    NonLinear := Formula.Method As IMsNonLinearRegressionTransform;
    //add a factor
    Varr := MB.ItemByIdNamespace("Var_Factor",Kont.Key).Bind As IVariableStub;
    Trans.Inputs.Add(Varr);
    TransVar := Trans.Inputs.Item(0);
    Slice := TransVar.SlicesTree(VarTrans).CreateSlice(1);
    //Compare term with slice in variable
    TermX1 := NonLinear.Operands.Add(Slice);
    TermX1Info := TermX1.TermInfo;
    //change parameters of the first term
    TermX1Info.Inversion:= MsInversion.DLog;
    TermX1Info.InversionLag:= MsInversionLag.PrecidingYear;
    TermX1Info.Lag := "-1";
    TermX1.TermInfo := TermX1Info;
    //create an equation
    NonLinear.Expression.AsString:= "A0+" + TermX1Info.TermInnerText + "/10";
    MObj.Save;
End Sub UserProc;

After executing the example, a new model is created in the modeling container. The output variable and one input variable is added into the model. For making the equation the term, that refers to the slice of input variable, is created. The way of initial transformation of data and lag is changed for the term. The non-linear regression method will be used for model calculation.

See also:

IMsFormulaTermInfo