Transform(Selector: IMsFormulaTransformSelector): IMsFormula;
Selector. The object, which determines the slice of the variable, by which it is necessary to set up calculation method parameters.
The Transform property returns the object allowing to set up calculation method parameters. If the output variable contains additional dimensions, there is a possibility for each slice to determine its own calculation method.
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("KONT_MODEL");
CrInf.Permanent := False;
MObj := Mb.CreateObject(CrInf).Edit;
Model := MObj As IMsModel;
Trans := Model.Transform;
//adding output variable
Varr := MB.ItemByIdNamespace("Var_11", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;
Model.Output.Add(Varr);
For i := 0 To Varr.Dimensions.Count - 1 Do
Trans.DimensionTransparent(Model.Transform.Outputs.Item(0), Varr.Dimensions.Item(i).Model) := True;
End For;
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("KONT_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. For calculating the model the method of linear regression is used. The output variable and one factor are set for the model. If the output variable has additional dimensions, they will use common specification of calculation.
See also: