w2: IMsFormulaTerm;
The w2 property determines the weights 2.
Executing the example requires a modeling container with the CONT_MODEL identifier. Five modeling variables with the SOURCE_LRX, RESULT_LRX, AVAL_LRX, APD_LRX, and W1_LRX identifiers must be available in this container.
Sub Main;
Var
ActiveMetabase: IMetabase;
CrInf: IMetabaseObjectCreateInfo;
ModelCont, Descript: IMetabaseObjectDescriptor;
Obj, Obj_x1: IMetabaseObject;
Model: IMsModel;
Transform: IMsFormulaTransform;
Out, Inp: IMsFormulaTransformVariables;
TransformVar: IMsFormulaTransformVariable;
Slice: IMsFormulaTransformSlice;
Selector: IMsFormulaTransformSelector;
Formula: IMsFormula;
LRX: IMsLRXFilterTransform;
Term: IMsFormulaTerm;
ModelVar_x1: IVariableStub;
Begin
ActiveMetabase := MetabaseClass.Active;
ModelCont := ActiveMetabase.ItemById("CONT_MODEL");
// Creating new model
CrInf := ActiveMetabase.CreateCreateInfo;
CrInf.ClassId := MetabaseObjectClass.KE_CLASS_MSMODEL;
CrInf.Id := "NEW_LRX_MODEL";
CrInf.Name := "NEW_LRX_MODEL";
CrInf.Parent := ModelCont;
CrInf.Permanent := False;
Obj := ActiveMetabase.CreateObject(CrInf).Edit;
Model := Obj As IMsModel;
Model.TreatNullsAsZeros := True;
Transform := Model.Transform;
// Determine output variable
Descript := ActiveMetabase.ItemByIdNamespace("SOURCE_LRX", ModelCont.Key);
Obj_x1 := Descript.Bind;
ModelVar_x1 := Obj_x1 As IVariableStub;
Out := Transform.Outputs;
Out.Clear;
Out.Add(ModelVar_x1);
// Setting model type
TransformVar := Transform.Outputs.Item(0);
Slice := TransformVar.Slices.Add(Null);
Selector := Transform.CreateSelector;
Selector.Slice := Slice;
Formula := Transform.Transform(Selector);
Formula.Kind := MsFormulaKind.LRXFilter;
LRX := Formula.Method As IMsLRXFilterTransform;
// loaded variable
Descript := ActiveMetabase.ItemByIdNamespace("RESULT_LRX", ModelCont.Key);
Obj_x1 := Descript.Bind;
ModelVar_x1 := Obj_x1 As IVariableStub;
LRX.Fitted := ModelVar_x1;
// Prior values
Descript := ActiveMetabase.ItemByIdNamespace("AVAL_LRX", ModelCont.Key);
Obj_x1 := Descript.Bind;
ModelVar_x1 := Obj_x1 As IVariableStub;
Inp := Transform.Inputs;
TransformVar := Inp.Add(ModelVar_x1);
Slice := TransformVar.Slices.Add(Null);
Term := LRX.Operands.Add(Slice);
LRX.Prior := Term;
// Prior differences
Descript := ActiveMetabase.ItemByIdNamespace("APD_LRX", ModelCont.Key);
Obj_x1 := Descript.Bind;
ModelVar_x1 := Obj_x1 As IVariableStub;
TransformVar := Inp.Add(ModelVar_x1);
Slice := TransformVar.Slices.Add(Null);
Term := LRX.Operands.Add(Slice);
LRX.DPrior := Term;
// Weights 1
Descript := ActiveMetabase.ItemByIdNamespace("W1_LRX", ModelCont.Key);
Obj_x1 := Descript.Bind;
ModelVar_x1 := Obj_x1 As IVariableStub;
TransformVar := Inp.Add(ModelVar_x1);
Slice := TransformVar.Slices.Add(Null);
Term := LRX.Operands.Add(Slice);
LRX.w1 := Term;
// Smoothing parameter
LRX.SmoothingParameter := 120.1;
// Missing data treatment method
LRX.MissingData.Method := MissingDataMethod.LinTrend;
// Residuals upload
LRX.Residuals:=Null;
Obj.Save;
End Sub Main;
After executing the example a model with the NEW_LRX_MODEL identifier that uses the LRX-filter method for calculation is created in the modeling container. The output variable, loaded variable, prior values and differences, weights 1, smoothing and residual load parameters, and missing data treatment method are determined for the model.
See also: