IMsFormulaTransform.EquationsFormula

Syntax

EquationsFormula: IMsFormula;

Description

The EquationsFormula property returns equations formula. Used for working with the error correction model and the system of non-linear equations.

Example

Sub Main;

Var

MB: IMetabase;

CrInf: IMetabaseObjectCreateInfo;

MObj: IMetabaseObject;

Model: IMsModel;

ECM: IMsErrorCorrectionModelTransform;

Endo1, Endo2, Endo3, Ekzo1: IMsVariable;

TransVar: IMsFormulaTransformVariable;

Tree: IMsFormulaTransformSlicesTree;

Slice: IMsFormulaTransformSlice;

Selector: IMsFormulaTransformSelector;

Formula: IMsFormula;

Eqution: IMsECMEquation;

ComposTerm: IMsCompositeFormulaTerm;

Begin

MB := MetabaseClass.Active;

//create a model

CrInf := Mb.CreateCreateInfo;

CrInf.ClassId := MetabaseObjectClass.KE_CLASS_MSMODEL;

CrInf.Id := "New_ECM";

CrInf.Name := "New_ECM";

CrInf.Parent := Mb.ItemById("KONT_MODEL");

CrInf.Permanent := False;

MObj := Mb.CreateObject(CrInf).Edit;

Model := MObj As IMsModel;

Model.Kind := MsModelKind.ErrorCorrectionModel;

//setting model parameters

ECM := Model.Transform.EquationsFormula.Method As IMsErrorCorrectionModelTransform;

ECM.ModelType := ECMType.NoTrendIntercept;

ECM.CointegralCount := 2;

// adding of endogenous variables to the list of outputs

Endo1 := MB.ItemByIdNamespace("Var_1", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;

Model.Output.Add(Endo1);

Endo2 := MB.ItemByIdNamespace("Var_2", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;

Model.Output.Add(Endo2);

Endo3 := MB.ItemByIdNamespace("Var_3", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;

Model.Output.Add(Endo3);

// adding of endogenous variable to the list of the inputs

Ekzo1 := MB.ItemByIdNamespace("Var_11", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;

Model.Input.Add(Ekzo1);

// configuration of the first endogenous variable

TransVar := Model.Transform.Outputs.Item(0);

Tree := TransVar.SlicesTree(Null);

Slice := Tree.CreateSlice(1);

Selector := Endo1.Transform.CreateSelector;

Selector.Slice := Slice;

Formula := Model.Transform.Transform(Selector);

Formula.Kind := MsFormulaKind.ECMEquation;

Formula.Level := DimCalendarLevel.Year;

Eqution := Formula.Method As IMsECMEquation;

Eqution.Inversion := MsInversion.Normalization;

// configuration of the endogenous variable for the first equation

TransVar := Model.Transform.Inputs.Item(0);

ComposTerm := Eqution.Operands.Add;

Slice := TransVar.Slices.Add(Null);

ComposTerm.Expression.AsString := "10*" + Model.Transform.SliceToTerm(Slice, "") + "*3.14";

// configuration of the second endogenous variable

TransVar := Model.Transform.Outputs.Item(1);

Tree := TransVar.SlicesTree(Null);

Slice := Tree.CreateSlice(1);

Selector := Endo1.Transform.CreateSelector;

Selector.Slice := Slice;

Formula := Model.Transform.Transform(Selector);

Formula.Kind := MsFormulaKind.ECMEquation;

// configuration of the third endogenous variable

TransVar := Model.Transform.Outputs.Item(2);

Tree := TransVar.SlicesTree(Null);

Slice := Tree.CreateSlice(1);

Selector := Endo1.Transform.CreateSelector;

Selector.Slice := Slice;

Formula := Model.Transform.Transform(Selector);

Formula.Kind := MsFormulaKind.ECMEquation;

MObj.Save;

End Sub Main;

After executing the example, the error correction model is created in the modeling container. For this model, the key parameters (model type and number of cointegration connections) are determined, 3 variables are added to the list of endogenous variables. One endogenous variable is added for the first equation.

See also:

IMsFormulaTransform