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, an array of values must be assigned for this property, to flush the coefficients, the Null value must be assigned.

Example

Executing the example requires that the modeling container includes a model that uses the linear regression (OLS estimation) method for calculation.

Sub Main;

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..1] Of 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(1990, 01, 01);

Calc.Period.IdentificationEndDate := DateTime.ComposeDay(2000, 12, 31);

Calc.Period.ForecastStartDate := DateTime.ComposeDay(2001, 01, 01);

Calc.Period.ForecastEndDate := DateTime.ComposeDay(2010, 12, 31);

Coord := Trans.CreateCoord(VarTrans);

//identification of new equation

Linear.Identify(Calc As IMsMethodCalculation, Coord);

//receive the calculated coefficients

Coef := Linear.Coefficients(Coord);

//save if it is not saved

If Not Linear.IsCoefficientsSaved(Coord) Then

Linear.Coefficients(Coord) := Coef;

End If;

//display into the console

For i := 0 To Coef.Length - 1 Do

Debug.WriteLine(Coef[i]);

End For;

MObj.Save;

End Sub Main;

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

See also:

IMsLinearRegressionTransform