PairCorrelationMatrix(Calculation: IMsMethodCalculation; Coord: IMsFormulaTransformCoord): Array;
Calculation. Settings required for model calculation.
Coord. The output variable slice for which calculation is performed.
The PairCorrelationMatrix property returns a real array containing correlation matrix.
Executing the example requires that the modeling container includes a model that uses the linear regression (OLS estimation) method for calculation.
Sub Main;
Var
MB: IMetabase;
MObj: IMetabaseObject;
Model: IMsModel;
Trans: IMsFormulaTransform;
VarTrans: IMsFormulaTransformVariable;
Tree: IMsFormulaTransformSlicesTree;
Slice: IMsFormulaTransformSlice;
Selector: IMsFormulaTransformSelector;
Formula: IMsFormula;
Linear: IMsLinearRegressionTransform;
Calc: IMsModelCalculation;
Coord: IMsFormulaTransformCoord;
PairArr: Array Of Double;
i, j: Integer;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemByIdNamespace("NEW_LINREG", MB.ItemById("KONT_MODEL").Key).Edit;
Model := MObj As IMsModel;
Trans := Model.Transform;
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);
Linear := Formula.Method As IMsLinearRegressionTransform;
Calc := Model.CreateCalculation;
Calc.Period.IdentificationStartDate := DateTime.ComposeDay(1990, 01, 01);
Calc.Period.IdentificationEndDate := DateTime.ComposeDay(2000, 12, 31);
Calc.Period.ForecastStartDate := DateTime.ComposeDay(2001, 01, 01);
Calc.Period.ForecastEndDate := DateTime.ComposeDay(2010, 12, 31);
Coord := Trans.CreateCoord(VarTrans);
//identification of equation
Linear.Identify(Calc As IMsMethodCalculation, Coord);
PairArr := Linear.PairCorrelationMatrix(Calc As IMsMethodCalculation, Coord);
For i := 0 To PairArr.GetUpperBound(1) Do
For j := 0 To PairArr.GetUpperBound(2) Do
Debug.Write(String.Format("{0,6:F}", PairArr[i, j]));
End For;
Debug.WriteLine("");
End For;
MObj.Save;
End Sub Main;
After executing the example the model equation coefficients are identified, and correlation matrix is displayed in the console window.
See also: