PairCorrelationMatrix(Calculation: IMsMethodCalculation; Coord: IMsFormulaTransformCoord): Array;
Calculation. Model calculation options.
Coord. Output variable slice, for which calculation is executed.
The PairCorrelationMatrix property returns the matrix of model factor correlation.
Coord and Calculation cannot be set to Null.
The correlation matrix is a 3D array of real numbers. The size of the first dimension is matched with the size of the explained variable.
Executing the example requires that the repository contains a modeling container with the OBJ_MS identifier. This container must include a model with the MODEL identifier that uses panel data regression method for calculation.
Add links to the Metabase, Ms, Stat system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MsKey: Integer;
MObj: IMetabaseObject;
Model: IMsModel;
Trans: IMsFormulaTransform;
VarTrans: IMsFormulaTransformVariable;
Formula: IMsFormula;
PooledModel: IMsPooledModelTransform;
Calc: IMsModelCalculation;
CalcMethod: IMsMethodCalculation;
Coord: IMsFormulaTransformCoord;
CorrelationMatrix: Array Of Double;
i, j, k: integer;
Explanded: IMsFormulaTermSet;
Begin
MB := MetabaseClass.Active;
MsKey := Mb.ItemById("OBJ_MS").Key;
MObj := MB.ItemByIdNamespace("MODEL", MsKey).Bind;
Model := MObj As IMsModel;
Trans := Model.Transform;
VarTrans := Trans.Outputs.Item(0);
Formula := Trans.FormulaItem(0);
PooledModel := Formula.Method As IMsPooledModelTransform;
Calc := Model.CreateCalculation;
Calc.Period.IdentificationStartDate := DateTime.ComposeDay(2000, 01, 01);
Calc.Period.IdentificationEndDate := DateTime.ComposeDay(2006, 12, 31);
Calc.Period.ForecastStartDate := DateTime.ComposeDay(2007, 01, 01);
Calc.Period.ForecastEndDate := DateTime.ComposeDay(2010, 12, 31);
Coord := Trans.CreateCoord(VarTrans);
CalcMethod := Calc As IMsMethodCalculation;
//identification of equation
PooledModel.Identify(CalcMethod, Coord);
Explanded := PooledModel.Explained;
//get calculated coefficients
CorrelationMatrix := PooledModel.PairCorrelationMatrix(CalcMethod, Coord);
For i := 0 To CorrelationMatrix.GetUpperBound(1) Do
Debug.WriteLine(Explanded.Item(i).TermToText);
For j := 0 To CorrelationMatrix.GetUpperBound(2) Do
For k := 0 To CorrelationMatrix.GetUpperBound(3) Do
Debug.Write(String.Format("{0,6:F}", CorrelationMatrix[i, j, k].ToString));
End For;
Debug.WriteLine("");
End For;
End For;
End Sub UserProc;
After executing the example coefficients of factor correlation for each slice of the explained model variable are displayed in the console window.
See also: