IMsPooledModelTransform.PairCorrelationMatrix

Syntax

PairCorrelationMatrix(Calculation: IMsMethodCalculation; Coord: IMsFormulaTransformCoord): Array;

Parameters

Calculation. Model calculation parameters.

Coord. Output variable slice, for which calculation is executed.

Description

The PairCorrelationMatrix property returns the matrix of model factor correlation.

Comments

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.

Example

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(20000101);
        Calc.Period.IdentificationEndDate := DateTime.ComposeDay(20061231);
        Calc.Period.ForecastStartDate := DateTime.ComposeDay(20070101);
        Calc.Period.ForecastEndDate := DateTime.ComposeDay(20101231);
        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(1Do
            Debug.WriteLine(Explanded.Item(i).TermToText);
            For j := 0 To CorrelationMatrix.GetUpperBound(2Do
                For k := 0 To CorrelationMatrix.GetUpperBound(3Do
                    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:

IMsPooledModelTransform