ConfidenceLevel: Double;
The ConfidenceLevel property determines the confidence limits relevance. By default the value 0.95 is set to the property.
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;
CrInf: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
Model: IMsModel;
Trans: IMsFormulaTransform;
VarTrans: IMsFormulaTransformVariable;
Tree: IMsFormulaTransformSlicesTree;
Slice: IMsFormulaTransformSlice;
Selector: IMsFormulaTransformSelector;
Formula: IMsFormula;
Linear: IMsLinearRegressionTransform;
Varr: IMsVariableStub;
TransVar: IMsFormulaTransformVariable;
TermInfo: IMsFormulaTermInfo;
Ar: Array[0..1] Of Integer;
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;
Varr := MB.ItemByIdNamespace("Var_1", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariableStub;
Trans.Outputs.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;
Linear := Formula.Method As IMsLinearRegressionTransform;
Ar[0] := 2;
Ar[1] := 4;
Linear.AutoRegressionOrder := Ar;
Linear.HasConstant := True;
Varr := MB.ItemByIdNamespace("Var_Factor", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariableStub;
Trans.Inputs.Add(Varr);
TransVar := Trans.Inputs.Item(0);
TermInfo := Trans.CreateTermInfo;
TermInfo.Slice := TransVar.SlicesTree(VarTrans).CreateSlice(1);
Linear.Explanatories.Add.Expression.AsString := TermInfo.TermInnerText;
Linear.ConfidenceLevel := 0.99;
MObj.Save;
End Sub Main;
After executing the example a model is created in the modeling container. The linear regression method is used for model calculation. Settings are determined for this method, in particular the autoregression is used. Autoregression order is two, two and four lags are set for the autoregression elements. The value 0.99 is set for a significance value of confidential limits.
See also: