IMsPairCorrelationTestSettings.BalancedSample

Syntax

BalancedSample: Boolean;

Description

The BalancedSample property determines which observations are used to estimate correlation coefficients.

Comments

The property is relevant if the missing data treatment uses the  MissingDataMethod.Casewise method. The missing data treatment method is determined by the IMsVariableTestSettings.MissingData property.

Available values BalancedSample:

Example

Executing the example requires that the repository contains a modeling container with the MODEL_SPACE identifier containing a modeling problem with the WEB_PROBLEM identifier. This problem must contain the internal metamodel containing the internal time series database and variables.

Add links to the Metabase, Ms system assemblies.

Sub PairCorrelation;
Var
    mb: IMetabase;
    msKey: Integer;
    Problem: IMsProblem;
    MetaObj: IMetabaseObject;
    Meta: IMsMetaModel;
    MetaVisual: IMsMetaModelVisualController;
    VarTest: IMsVariableTest;
    PairCorr: IMsPairCorrelationTestSettings;
    Sources: IMsVariableTestDataList;
    TestData: IMsVariableTestData;
    i, j: Integer;
    VarArray: Array;
    Slice: IMsFormulaTransformSlice;
    TestRes: IMsVariableTestResults;
    Res: Array;
Begin
    mb := MetabaseClass.Active;
    // Get modelling container key
    msKey := mb.GetObjectKeyById("MODEL_SPACE");
    // Get modeling problem
    Problem := mb.ItemByIdNamespace("WEB_PROBLEM", msKey).Bind As IMsProblem;
    // Get metamodel
    MetaObj := Problem.MetaModel As IMetabaseObject;
    Meta := MetaObj.Edit As IMsMetaModel;
    MetaVisual := Meta.VisualController;
    // Get correlation matrix calculation options
    VarTest := MetaVisual.PairCorrelationTest;
    PairCorr := VarTest.Settings As IMsPairCorrelationTestSettings;
    // Correlation coefficients are calculated by all possible data
    PairCorr.BalancedSample := False;
    // Add checking variables only with the annual frequency
    Sources := PairCorr.IncludedSources;
    If Sources.Count > 0 Then
        Sources.Clear;
    End If;
    VarArray := MetaVisual.GetVariables;
    For i := 0 To VarArray.Length - 1 Do
        Slice := VarArray[i] As IMsFormulaTransformSlice;
        If Slice.Level = DimCalendarLevel.Year Then
            TestData := Sources.Add(Slice, Slice.Key);
            Debug.WriteLine("Key of tested variable: " + TestData.EntryKey.ToString);
        End If;
    End For;
    // Setting calculation period
    PairCorr.StartDate := DateTime.Parse("01.01.2000");
    PairCorr.EndDate := DateTime.Parse("01.01.2014");
    // Perform calculation
    TestRes := VarTest.Execute;
    // Display correlation matrix in the console window
    Res := TestRes.ResValueMatrix;
    For i := 0 To Res.GetUpperBound(1Do
        For j := 0 To Res.GetUpperBound(2Do
            Debug.Write(Res[i, j]);
            Debug.Write(";  ");
        End For;
        Debug.WriteLine("");
    End For;
End Sub PairCorrelation;

Example execution result: for all variables of the annual frequency, which are contained in the calculation chain of the metamodel, the correlation matrix is calculated. The results are displayed in the console window.

See also:

IMsPairCorrelationTestSettings