IMsMetaModelVisualController.JohansenTest

Fore Syntax

JohansenTest: IMsVariableTest

Fore.NET Syntax

JohansenTest: Prognoz.Platform.Interop.Ms.IMsVariableTest;

Description

The JohansenTest property returns parameters of the Johansen test calculation

Comments

Use the IMsJohansenTestSettings interface to set up calculation parameters.

Fore Example

Executing the example requires that the repository contains a modeling container with the MS identifier containing a modeling problem with the WEB_PROBLEM identifier. The task must contain the internal metamodel. The metamodel must contain not less than three internal variables.

Add links to the Metabase, Ms, Stat system assemblies.

Sub JohansenTest;
Var
    mb: IMetabase;
    msKey: Integer;
    Problem: IMsProblem;
    Meta: IMsMetaModel;
    MetaVisual: IMsMetaModelVisualController;
    ChainEnts: IMsCalculationChainEntries;
    ChainEl: IMsCalculationChainEntry;
    Test: IMsVariableTest;
    CommonSett: IMsVariableTestSettings;
    InclSrc: IMsVariableTestDataList;
    VarArray: Array Of Variant;
    i, j: Integer;
    TestData: IMsVariableTestData;
    Johansen: IMsJohansenTestSettings;
    TestRes: IMsVariableTestResults;
    Res: Array;
Begin
    mb := MetabaseClass.Active;
    // Get modelling container key
    msKey := mb.GetObjectKeyById("MS");
    // Get modeling problem
    Problem := mb.ItemByIdNamespace("WEB_PROBLEM", msKey).Bind As IMsProblem;
    // Get metamodel
    Meta := Problem.MetaModel;
    MetaVisual := Meta.VisualController;
    // Get time metamodels
    ChainEnts := Meta.CalculationChain;
    j := 0;
    VarArray := New Variant[ChainEnts.Count];
    For i := 0 To ChainEnts.Count - 1 Do
        ChainEl := ChainEnts.Item(i);
        If ChainEl.Type = MsCalculationChainEntryType.Variable Then
            VarArray[j] := ChainEl;
            j := j + 1;
        End If;
    End For;
    // Set endogenous variables for test calculation
    For i := 1 To j - 1 Do
        ChainEl := VarArray[i] As IMsCalculationChainEntry;
        MetaVisual.AddTestIncludedEntrie(ChainEl.Key, MsVariableTestType.Johansen);
    End For;
    // Set exogenous variables for test calculation
    ChainEl := VarArray[0As IMsCalculationChainEntry;
    MetaVisual.AddJohansenTestExogenousEntrie(ChainEl.Key);
    // Set common parameters of calculating the descriptive statistics
    Test := MetaVisual.JohansenTest;
    CommonSett := Test.Settings;
    // Calculation period
    CommonSett.StartDate := DateTime.Parse("01.01.1990");
    CommonSett.EndDate := DateTime.Parse("01.01.2015");
    // Method of missing data treatment
    CommonSett.MissingData.Method := MissingDataMethod.LinTrend;
    // Set Johnsen test calculation parameters
    Johansen := CommonSett As IMsJohansenTestSettings;
    // Determinenbsp;autoregressionnbsp;order
    Johansen.AutoRegressionOrder := "1";
    // Set the type of error correction model
    Johansen.ModelType := ECMType.TrendTrend;
    // Display the information about the tested variables
    InclSrc := Johansen.IncludedSources;
    Debug.WriteLine("Endogenous variables:");
    For i := 0 To InclSrc.Count - 1 Do
        TestData := InclSrc.Item(i);
        Debug.WriteLine("    " + TestData.Name);
    End For;
    Debug.WriteLine("Exogenous variable:");
    InclSrc := Johansen.ExogenousSources;
    TestData := InclSrc.Item(0);
    Debug.WriteLine("    " + TestData.Name);
    // Perform calculation of the test
    TestRes := Test.Execute;
    // Output results
    If TestRes.Error <> "" Then
        Debug.WriteLine(TestRes.Error);
    Else
        Res := TestRes.ResValueMatrix;
        Debug.WriteLine("");
        Debug.WriteLine("Johansen test");
        Debug.WriteLine("");
        For i := 0 To Res.GetUpperBound(1Do
            Select Case i
                Case 0: Debug.Write("Links: ");
                Case 1: Debug.Write("Eigenvalue: ");
                Case 2: Debug.Write("Maximum likehood ratio: ");
                Case 3: Debug.Write("Critical value is 1%: ");
                Case 4: Debug.Write("   Hypothesis is accepted: ");
                Case 5: Debug.Write("Critical value is 5%: ");
                Case 6: Debug.Write("   Hypothesis is accepted: ");
                Case 7: Debug.Write("Critical value is 10%: ");
                Case 8: Debug.Write("    Hypothesis is accepted: ");
                Case 9: Debug.Write("Probability: ");
            End Select;
            For j := 0 To Res.GetUpperBound(2Do
                Debug.Write(Res[i, j]); Debug.Write(";    ");
            End For;
            Debug.WriteLine("");
        End For;
    End If;
End Sub JohansenTest;

Example execution result: the Johansen test is calculated for all variables which are contained in the metamodel calculation chain. The results are displayed in the console window.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Stat;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    msKey: uinteger;
    Problem: IMsProblem;
    Meta: IMsMetaModel;
    MetaVisual: IMsMetaModelVisualController;
    ChainEnts: IMsCalculationChainEntries;
    ChainEl: IMsCalculationChainEntry;
    Test: IMsVariableTest;
    CommonSett: IMsVariableTestSettings;
    InclSrc: IMsVariableTestDataList;
    VarArray: Array Of Object;
    i, j: Integer;
    TestData: IMsVariableTestData;
    Johansen: IMsJohansenTestSettings;
    TestRes: IMsVariableTestResults;
    Res: Array;
Begin
    mb := Params.Metabase;
    // Get modelling container key
    msKey := mb.GetObjectKeyById("MS");
    // Get modeling problem
    Problem := mb.ItemByIdNamespace["WEB_PROBLEM", msKey].Bind() As IMsProblem;
    // Get metamodel
    Meta := Problem.MetaModel;
    MetaVisual := Meta.VisualController;
    // Get time metamodels
    ChainEnts := Meta.CalculationChain;
    j := 0;
    VarArray := New Object[ChainEnts.Count];
    For i := 0 To ChainEnts.Count - 1 Do
        ChainEl := ChainEnts.Item[i];
        If ChainEl.Type = MsCalculationChainEntryType.mccetVariable Then
            VarArray[j] := ChainEl;
            j := j + 1;
        End If;
    End For;
    // Set endogenous variables for test calculation
    For i := 1 To j - 1 Do
        ChainEl := VarArray[i] As IMsCalculationChainEntry;
        MetaVisual.AddTestIncludedEntrie(ChainEl.Key, MsVariableTestType.mvttJohansen);
    End For;
    // Set exogenous variables for test calculation
    ChainEl := VarArray[0As IMsCalculationChainEntry;
    MetaVisual.AddJohansenTestExogenousEntrie(ChainEl.Key);
    // Set common parameters of calculating the descriptive statistics
    Test := MetaVisual.JohansenTest;
    CommonSett := Test.Settings;
    // Calculation period
    CommonSett.StartDate := DateTime.Parse("01.01.1990");
    CommonSett.EndDate := DateTime.Parse("01.01.2015");
    // Method of missing data treatment
    CommonSett.MissingData.Method := MissingDataMethod.mdmLinTrend;
    // Set the parameters of Johansen test calculation 
    Johansen := CommonSett As IMsJohansenTestSettings;
    // Determinenbsp;autoregressionnbsp;order
    Johansen.AutoRegressionOrder := "1";
    // Set the type of error correction model
    Johansen.ModelType := ECMType.ecmtTrendTrend;
    // Display the information about the tested variables
    InclSrc := Johansen.IncludedSources;
    System.Diagnostics.Debug.WriteLine("Endogenous variables:");
    For i := 0 To InclSrc.Count - 1 Do
        TestData := InclSrc.Item[i];
        System.Diagnostics.Debug.WriteLine("    " + TestData.Name);
    End For;
    System.Diagnostics.Debug.WriteLine("Exogenous variable:");
    InclSrc := Johansen.ExogenousSources;
    TestData := InclSrc.Item[0];
    System.Diagnostics.Debug.WriteLine("    " + TestData.Name);
    // Perform calculation of the test
    TestRes := Test.Execute();
    // Output results
    If TestRes.Error <> "" Then
        System.Diagnostics.Debug.WriteLine(TestRes.Error);
    Else
        Res := TestRes.ResValueMatrix;
        System.Diagnostics.Debug.WriteLine("");
        System.Diagnostics.Debug.WriteLine("Johansen test");
        System.Diagnostics.Debug.WriteLine("");
        For i := 0 To Res.GetUpperBound(1Do
            Select Case i
                Case 0: System.Diagnostics.Debug.Write("Links: ");
                Case 1: System.Diagnostics.Debug.Write("Eigenvalue: ");
                Case 2: System.Diagnostics.Debug.Write("Maximum likehood ratio: ");
                Case 3: System.Diagnostics.Debug.Write("Critical value is 1%: ");
                Case 4: System.Diagnostics.Debug.Write("   Hypothesis is accepted: ");
                Case 5: System.Diagnostics.Debug.Write("Critical value is 5%: ");
                Case 6: System.Diagnostics.Debug.Write("   Hypothesis is accepted: ");
                Case 7: System.Diagnostics.Debug.Write("Critical value is 10%: ");
                Case 8: System.Diagnostics.Debug.Write("    Hypothesis is accepted: ");
                Case 9: System.Diagnostics.Debug.Write("Probability: ");
            End Select;
            For j := 0 To Res.GetUpperBound(0Do
                System.Diagnostics.Debug.Write(Res[j, i]); System.Diagnostics.Debug.Write(";    ");
            End For;
            System.Diagnostics.Debug.WriteLine("");
        End For;
    End If;
End Sub;

See also:

IMsMetaModelVisualController