IMsFormula.Method

Syntax

Method: IMsMethod;

Description

The Method property returns parameters of the method used for model calculation.

Comments

To determine parameters of the selected 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 an output variable and a factor, respectively, are created in the container.

Add links to the Dimensions, Metabase, Ms system assemblies.

Sub UserProc;
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
    // Get the current repository
    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;
    //Add an 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;
    //Set up linear regression parameters
    Linear := Formula.Method As IMsLinearRegressionTransform;
    Varr := MB.ItemByIdNamespace("Var_Factor", MB.ItemById("CONT_MODEL").Key).Bind As IMsVariable;
    //Add 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 UserProc;

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

See also:

IMsFormula