IMsPooledModelTransform.Coefficients

Syntax

Coefficients(Coord: IMsFormulaTransformCoord): Array;

Parameters

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

Description

The Coefficients property determines an array of values of model equation coefficients.

Comments

Coord cannot be set to Null.

If the equation includes a constant, its value is specified in the last element of the Coefficients array.

To save the coefficients in Coefficients, it is necessary to place the values array to reset coefficients, that is, to set the Null value. The IMsPooledModelTransform.IsCoefficientsSaved property determines whether the coefficients are saved.

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;
        Coord: IMsFormulaTransformCoord;
        Coef: Array Of Double;
        StatCoef: IModelCoefficients;
        CoefficientsAR: ICoefficients;
        Sub PrintArray(Arr: Array Of Double);
        Var
            i: Integer;
        Begin
            i := Arr.Length;
            If i > 0 Then
                For i := 0 To Arr.Length - 1 Do
                    Debug.WriteLine("    " + Arr[i].ToString);
                End For;
            Else
                Debug.WriteLine("    values are not calculated");
            End If;
        End Sub PrintArray;
    Begin
        MB := MetabaseClass.Active;
        MsKey := Mb.ItemById("OBJ_MS").Key;
        MObj := MB.ItemByIdNamespace("MODEL", MsKey).Edit;
        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);
    //identification of equation
        PooledModel.Identify(Calc As IMsMethodCalculation, Coord);
    //get calculated coefficients
        Coef := PooledModel.Coefficients(Coord);
    //if coefficients are not saved , save them
        If Not PooledModel.IsCoefficientsSaved(Coord) Then
            PooledModel.Coefficients(Coord) := Coef;
        End If;
    //display model coefficients in the console
        Debug.WriteLine("Model coefficients:");
        PrintArray(Coef);
    //get and display model summary statistics in the console
        StatCoef := PooledModel.StatCoefficients(Coord);
        Coef := StatCoef.Coefficients.StandardError;
        Debug.WriteLine("Standard error:");
        PrintArray(Coef);
    //get and display autoregression coefficients
        CoefficientsAR := PooledModel.ARMACoefficients(Coord).CoefficientsAR;
        Debug.WriteLine("Autoregression coefficients:");
        Coef := CoefficientsAR.Estimate;
        PrintArray(Coef);
        MObj.Save;
    End Sub UserProc;

After executing the example the model coefficients are saved and displayed in the console window. The autoregression coefficients and part of summary statistics are displayed: the value of standard error.

See also:

IMsPooledModelTransform