WeightsMatrix(Calculation: IMsMethodCalculation;
Coord: IMsFormulaTransformCoord): Array;
Calculation. Settings that are necessary for model calculation.
Coord. The slice, by which calculation is executed.
The WeightsMatrix property returns weights matrix after method calculation.
The stationary Baxter-King filter is used that is why the calculated matrix contains one dimension: 1×(q+1), where q is the value of lead/lag parameter that is determined by the IMsBandpassFilterTransform.Width property.
Executing the example requires that the repository contains a modeling container with the CONT_MODEL identifier. The container contains variables with the VAR_BPF_CYCLE, VAR_BPF_NONCYCLE identifiers and a model with the MODEL_NEW_BPF identifier. The model uses the Baxter-King filter for calculation.
Add links to the Cubes, Metabase, Ms system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
ModelSpace, ModelObj: IMetabaseObject;
Transf: IMsFormulaTransform;
Formula: IMsFormula;
Model: IMsModel;
BandpassF: IMsBandpassFilterTransform;
TransSeries: IMsFormulaTransformVariables;
VarStab: IVariableStub;
TransVar: IMsFormulaTransformVariable;
TermInfo: IMsFormulaTermInfo;
Calculation: IMsMethodCalculation;
Coo: IMsFormulaTransformCoord;
Weights: Array Of Double;
i: Integer;
Begin
// Get the current repository
Mb := MetabaseClass.Active;
// Get model
ModelSpace := Mb.ItemById("CONT_MODEL").Bind;
ModelObj := Mb.ItemByIdNamespace("MODEL_NEW_BPF", ModelSpace.Key).Edit;
Model := ModelObj As IMsModel;
// Get model parameters
Transf := Model.Transform;
Formula := Transf.FormulaItem(0);
BandpassF := Formula.Method As IMsBandpassFilterTransform;
TransSeries := Transf.Series;
TermInfo := Transf.CreateTermInfo;
// Set component settings
If BandpassF.OutputType = MsBPFOutputType.CycleSeries Then
VarStab := Mb.ItemByIdNamespace("VAR_BPF_NONCYCLE", ModelSpace.Key).Bind As IVariableStub;
TransVar := TransSeries.Add(VarStab);
TermInfo.Slice := TransVar.Slices.Add(Null);
BandpassF.NonCyclicalTerm := TermInfo;
Else
VarStab := Mb.ItemByIdNamespace("VAR_BPF_CYCLE", ModelSpace.Key).Bind As IVariableStub;
TransVar := TransSeries.Add(VarStab);
TermInfo.Slice := TransVar.Slices.Add(Null);
BandpassF.CycleTerm := TermInfo;
End If;
// Set calculation options
Calculation := Transf.CreateCalculation;
Calculation.Period.ForecastEndDate := Model.Transform.Period.ForecastEndDate;
Calculation.Period.ForecastStartDate := Model.Transform.Period.ForecastStartDate;
Calculation.Period.IdentificationEndDate := Model.Transform.Period.IdentificationEndDate;
Calculation.Period.IdentificationStartDate := Model.Transform.Period.IdentificationStartDate;
Calculation.CurrentPoint := Model.Transform.Period.IdentificationStartDate;
Coo := Transf.CreateCoord(Transf.Outputs.Item(0));
// Execute calculation
BandpassF.Execute(Calculation, Coo);
Weights := BandpassF.WeightsMatrix(Calculation, Coo);
For i := 0 To Weights.Length - 1 Do
Debug.WriteLine(Weights[i]);
End For;
// Save model
ModelObj.Save;
End Sub UserProc;
After executing the example the variable, to which the cyclic and non-cyclic components (depending on the component loaded to the output variable) are loaded, is set for the model. The model is calculated, the weight matrix is displayed in the console window.
See also: