IMsFormula.Method

Syntax

Method: IMsMethod;

Description

The Method property returns parameters of the method used to calculate the model. To determine the parameters of chosen method, this property must be cast to the interface, that describes the calculation method.

Example

Executing the example requires that the repository contains a modeling container with the CONT_MODEL identifier. The variables with the Var_1 and Var_Factor identifiers, further used as a output variable and a factor, respectively, are created in the container.

Sub Main;

Var

MB: IMetabase;

CrInf: IMetabaseObjectCreateInfo;

MObj: IMetabaseObject;

Model: IMsModel;

Trans: IMsFormulaTransform;

VarTrans: IMsFormulaTransformVariable;

Tree: IMsFormulaTransformSlicesTree;

Slice: IMsFormulaTransformSlice;

Selector: IMsFormulaTransformSelector;

Formula: IMsFormula;

Linear: IMsLinearRegressionTransform;

Varr: IMsVariable;

TransVar: IMsFormulaTransformVariable;

Begin

MB := MetabaseClass.Active;

CrInf := Mb.CreateCreateInfo;

CrInf.ClassId := MetabaseObjectClass.KE_CLASS_MSMODEL;

CrInf.Id := "New_LinReg";

CrInf.Name := "New_LinReg";

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

CrInf.Permanent := False;

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

Model := MObj As IMsModel;

Trans := Model.Transform;

//adding output variable

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

Model.Output.Add(Varr);

VarTrans := Trans.Outputs.Item(0);

Tree := VarTrans.SlicesTree(VarTrans);

Slice := Tree.CreateSlice(1);

Selector := Model.Transform.CreateSelector;

Selector.Slice := Slice;

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

Formula.Kind := MsFormulaKind.LinearRegression;

Formula.Level := DimCalendarLevel.Year;

//transfer to parameters configuration of the linear regression

Linear := Formula.Method As IMsLinearRegressionTransform;

Varr := MB.ItemByIdNamespace("Var_Factor", MB.ItemById("CONT_MODEL").Key).Bind As IMsVariable;

//adding a factor

Model.Input.Add(Varr);

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

Linear.Explanatories.Add.Expression.AsString := Model.Transform.SliceToTerm(TransVar.SlicesTree(VarTrans).CreateSlice(1), "");

MObj.Save;

End Sub Main;

After executing the example, a new model is created in the modeling container. The linear regression method is used for model calculation. The output variable and one factor are set for the model.

See also:

IMsFormula