ConfidenceLevel: Double;
The ConfidenceLevel property determines the confidence limits relevance. The property is set to 0.95 by default.
Executing the example requires that the repository contains a modeling container with the MODEL_SPACE identifier. The container contains the Var_1 variable, further used as a modeling container, and the variables Ins_Var and Var_Factor, used as an instrumental variable and a factor respectively.
Add links to the Dimension, Cubes, Metabase, Ms, Stat system assemblies.
Sub UserProc;
Var
MB: IMetabase;
KM: IMetabaseObjectDescriptor;
CrInf: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
Model: IMsModel;
Trans: IMsFormulaTransform;
VarTrans: IMsFormulaTransformVariable;
Tree: IMsFormulaTransformSlicesTree;
Slice: IMsFormulaTransformSlice;
Selector: IMsFormulaTransformSelector;
Formula: IMsFormula;
SLS2: IMs2SLSTransform;
Varr: IVariableStub;
TransVar: IMsFormulaTransformVariable;
TermInfo: IMsFormulaTermInfo;
Begin
MB := MetabaseClass.Active;
KM := Mb.ItemById("MODEL_SPACE");
CrInf := Mb.CreateCreateInfo;
CrInf.ClassId := MetabaseObjectClass.KE_CLASS_MSMODEL;
CrInf.Id := "New_2SLS";
CrInf.Name := "New_2SLS";
CrInf.Parent := KM;
MObj := Mb.CreateObject(CrInf).Edit;
Model := MObj As IMsModel;
Trans := Model.Transform;
Varr := MB.ItemByIdNamespace("Var_1", KM.Key).Bind As IVariableStub;
VarTrans := Trans.Outputs.Add(Varr);
Tree := VarTrans.SlicesTree(VarTrans);
Slice := Tree.CreateSlice(1);
Selector := Model.Transform.CreateSelector;
Selector.Slice := Slice;
Formula := Model.Transform.Transform(Selector);
Formula.Kind := MsFormulaKind.SLS2;
Formula.Level := DimCalendarLevel.Year;
SLS2 := Formula.Method As IMs2SLSTransform;
SLS2.ConstantMode := InterceptMode.AutoEstimate;
//Instrumental variable
Varr := MB.ItemByIdNamespace("Ins_Var", KM.Key).Bind As IVariableStub;
TransVar := Trans.Inputs.Add(Varr);
TermInfo := Trans.CreateTermInfo;
TermInfo.Slice := TransVar.SlicesTree(VarTrans).CreateSlice(1);
SLS2.Instrumental.Add.Expression.AsString := TermInfo.TermInnerText;
//Factor
Varr := MB.ItemByIdNamespace("Var_Factor", KM.Key).Bind As IVariableStub;
TransVar := Trans.Inputs.Add(Varr);
TermInfo := Trans.CreateTermInfo;
TermInfo.Slice := TransVar.SlicesTree(VarTrans).CreateSlice(1);
SLS2.Explanatories.Add.Expression.AsString := TermInfo.TermInnerText;
SLS2.ConfidenceLevel := 0.99;
MObj.Save;
End Sub UserProc;
After executing the example a model is created in the modeling container. For model calculation use the method of linear regression (instrumental variables estimation). The output variable is set for the model, as well as, the factor and instrumental variable. The constant is present in model equation. The value 0.99 is set for a significance value of confidential limits.
See also: