Show contents 

Ms > Ms Assembly Interfaces > IMsLinearRegressionTransform > IMsLinearRegressionTransform.Coefficients

IMsLinearRegressionTransform.Coefficients

Syntax

Coefficients(Coord: IMsFormulaTransformCoord): Array;

Parameters

Coord. The output variable slice for which calculation is performed.

Description

The Coefficients property determines an array of values of model equation coefficients. If a constant is present in the equation, its value is specified in the last element of the array. To save the coefficients, assign an array of values to this property; to flush the coefficients, assign the Null value.

Example

Executing the example requires that the modeling container includes the model that uses the method of linear regression for calculation.

Sub UserProc;
Var
    MB: IMetabase;
    MObj: IMetabaseObject;
    Model: IMsModel;
    Trans: IMsFormulaTransform;
    VarTrans: IMsFormulaTransformVariable;
    Tree: IMsFormulaTransformSlicesTree;
    Slice: IMsFormulaTransformSlice;
    Selector: IMsFormulaTransformSelector;
    Formula: IMsFormula;
    Linear: IMsLinearRegressionTransform;
    Calc: IMsModelCalculation;
    Coord: IMsFormulaTransformCoord;
    Coef: Array Of Double;
    Ar: Array[0..1Of Integer;
    i: Integer;
Begin
    MB := MetabaseClass.Active;
    MObj := MB.ItemByIdNamespace("New_LinReg", MB.ItemById("KONT_MODEL").Key).Edit;
    Model := MObj As IMsModel;
    Trans := Model.Transform;
    VarTrans := Trans.Outputs.Item(0);
    Tree := VarTrans.SlicesTree(VarTrans);
    Slice := Tree.CreateSlice(1);
    Selector := Model.Transform.CreateSelector;
    Selector.Slice := Slice;
    Formula := Model.Transform.Transform(Selector);
    Linear := Formula.Method As IMsLinearRegressionTransform;
    Ar[0] := 2;
    Ar[1] := 3;
    Linear.AutoRegressionOrder := Ar;
    Calc := Model.CreateCalculation;
    Calc.Period.IdentificationStartDate := DateTime.ComposeDay(19900101);
    Calc.Period.IdentificationEndDate := DateTime.ComposeDay(20001231);
    Calc.Period.ForecastStartDate := DateTime.ComposeDay(20010101);
    Calc.Period.ForecastEndDate := DateTime.ComposeDay(20101231);
    Coord := Trans.CreateCoord(VarTrans);
    //identification of new equation
    Linear.Identify(Calc As IMsMethodCalculation, Coord);
    //get calculated coefficients
    Coef := Linear.Coefficients(Coord);
    //if not saved, then save
    If Not Linear.IsCoefficientsSaved(Coord) Then
        Linear.Coefficients(Coord) := Coef;
    End If;
    //display in the console
    For i := 0 To Coef.Length - 1 Do
        Debug.WriteLine(Coef[i]);
    End For;
    MObj.Save;
End Sub UserProc;

After executing the example the model parameters are modified and new equation coefficients are calculated. Unsaved coefficient values are saved and displayed in the console window.

See also:

IMsLinearRegressionTransform