Lag: String;
The Lag property determines the lag value for the term. The lag indicates the shift of element index, the value of which is used during the calculation in this point. By default, the value 0 is set for property, at that the value of current element is used.
Executing the example requires that the repository contains a modeling container with the KONT_MODEL identifier. The container contains the Var_1 variable, further used as a output variable, and also the Var_Factor variable, used as a factor.
Sub Main;
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 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;
//adding 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);
//comparison of term to the slice in the variable
TermX1 := NonLinear.Operands.Add(Slice);
TermX1Info := TermX1.TermInfo;
//changing parameters of the first term
TermX1Info.Inversion := MsInversion.DLog;
TermX1Info.InversionLag := MsInversionLag.PrecidingYear;
TermX1Info.Lag := "-1";
TermX1.TermInfo := TermX1Info;
//creation of the equation
NonLinear.Expression.AsString := "A0+" + TermX1Info.TermInnerText + "/10";
MObj.Save;
End Sub Main;
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 method of non-linear regression is used for model calculation.
See also: