IMsDiagnosticTestResults.CoefficientsNames

Syntax

CoefficientsNames: Array;

Description

The CoefficientsNames property returns names of coefficients.

Comments

To get values of coefficients, use the IMsDiagnosticTestResults.ModelCoefficients property.

Example

Executing the example requires that the repository contains a modeling container with the MS identifier containing a modeling problem with the MODEL_RESETTEST_WEB identifier. The problem must be created in the web application and contain only a linear regression model.

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

Sub DiagnosticTests;
Var
    mb: IMetabase;
    MSKey: Integer;
    Problem: IMsProblem;
    Meta: IMsMetaModel;
    ChainEnts: IMsCalculationChainEntries;
    ChainEl: IMsCalculationChainEntry;
    pModel: IMsModel;
    pTransform: IMsFormulaTransform;
    pFormula: IMsFormula;
    pRegress: IMsLinearRegressionTransform;
    pTestList: IMsDiagnosticTestList;
    Test: IMsDiagnosticTest;
    VarTrans: IMsFormulaTransformVariable;
    Settings: IMsDiagnosticTestSettings;
    Calc: IMsMethodCalculation;
    Coord: IMsFormulaTransformCoord;
    Res: IMsDiagnosticTestResults;
    Stat: ISpecificationTestStatistic;
    i: Integer;
    Coef: ICoefficients;
    CoefNames: Array Of String;
Begin
    mb := MetabaseClass.Active;
    // Get modeling problem
    MSKey := mb.GetObjectKeyById("MS");
    Problem := mb.ItemByIdNamespace("MODEL_RESETTEST_WEB", MSKey).Bind As IMsProblem;
    // Get internal metamodel
    Meta := Problem.MetaModel;
    // Get linear regression problem
    ChainEnts := Meta.CalculationChain;
    For i := 0 To ChainEnts.Count - 1 Do
        ChainEl := ChainEnts.Item(i);
        If ChainEl.Type = MsCalculationChainEntryType.Model Then
            pModel := (ChainEl As IMsCalculationChainModel).Model;
        End If;
    End For;
    // Get model calculation parameters
    pTransform := pModel.Transform;
    pFormula := pTransform.FormulaItem(0);
    pRegress := pFormula.Method As IMsLinearRegressionTransform;
    // Get set of diagnostic tests
    pTestList := pRegress.DiagnosticTests;
    // Find the Ramsey RESET test
    Test := pTestList.FindByType(MsDiagnosticTestType.RamseyResset);
    VarTrans := pTransform.Outputs.Item(0);
    // Get test settings
    Settings := Test.Settings;
    // Set significance level
    Settings.ConfidenceLevel := 0.75;
    // Check if test can be calculated by means of R package
    If Settings.SupportsR
        Then
            Settings.UseR := True;
            Debug.WriteLine("Test is calculated by means of connection to R");
        Else
            Debug.WriteLine("Test does not support calculation by means of R");
    End If;
    Debug.WriteLine("");
    // Set testing periods
    Coord := pTransform.CreateCoord(VarTrans);
    Calc := pModel.CreateCalculation As IMsMethodCalculation;
    Calc.Period.IdentificationStartDate := pTransform.Period.IdentificationStartDate;
    Calc.Period.IdentificationEndDate := pTransform.Period.IdentificationEndDate;
    Calc.Period.ForecastStartDate := pTransform.Period.ForecastStartDate;
    Calc.Period.ForecastEndDate := pTransform.Period.ForecastEndDate;
    // Execute testing
    Res := Test.Execute(Calc As IMsMethodCalculation, Coord);
    // Output results
    If Res.Error <> "" Then
        Debug.WriteLine(Res.Error);
    Else
        Stat := Res.ChiTest;
        Debug.WriteLine("-- Chi-square statistic --");
        Debug.WriteLine("     Value: " + Stat.Statistic.ToString);
        Debug.WriteLine("     Probability: " + Stat.Probability.ToString);
        If Res.FTestResult Then
            Debug.WriteLine("     The hypothesis of functional form acceptability is accepted");
        Else
            Debug.WriteLine("     The hypothesis functional form acceptability is rejected");
        End If;
        Stat := Res.FTest;
        Debug.WriteLine("-- Fisher statistic --");
        Debug.WriteLine("     Value: " + Stat.Statistic.ToString);
        Debug.WriteLine("     Probability: " + Stat.Probability.ToString);
        If Res.ChiTestResult Then
            Debug.WriteLine("     The hypothesis of functional form acceptability is accepted");
        Else
            Debug.WriteLine("     The hypothesis of functional form acceptability is rejected");
        End If;
        CoefNames := Res.CoefficientsNames;
        Debug.WriteLine("-- Model coefficients values --");
        Coef := Res.ModelCoefficients.Coefficients;
        For i := 0 To Coef.Estimate.Length - 1 Do
            Debug.WriteLine("   Coefficient " + CoefNames[i]);
            Debug.WriteLine("     Value: " + Coef.Estimate[i].ToString);
            Debug.WriteLine("     Probability: " + Coef.Probability[i].ToString);
        End For;
        CoefNames := Res.CoefficientsARNames;
        If CoefNames.Length <> 0 Then
            Debug.WriteLine("-- Autoregression coefficients --");
            Coef := Res.CoefficientsAR;
            For i := 0 To CoefNames.Length - 1 Do
            Debug.WriteLine("   Coefficient " + CoefNames[i]);
            Debug.WriteLine("     Value: " + Coef.Estimate[i].ToString);
            Debug.WriteLine("     Probability: " + Coef.Probability[i].ToString);
            End For;
        End If;
        CoefNames := Res.CoefficientsMANames;
        If CoefNames.Length <> 0 Then
        Debug.WriteLine("-- Moving average coefficients --");
        Coef := Res.CoefficientsMA;
            For i := 0 To CoefNames.Length - 1 Do
            Debug.WriteLine("   Coefficient " + CoefNames[i]);
            Debug.WriteLine("     Value: " + Coef.Estimate[i].ToString);
            Debug.WriteLine("     Probability: " + Coef.Probability[i].ToString);
            End For;
        End If;
    End If;
End Sub DiagnosticTests;

After executing the example, the Ramsey RESET test is executed for the model, results are displayed in the console window. R package will be used in calculation.

See also:

IMsDiagnosticTestResults