IMsLinearRegressionTransform.IsCoefficientsSaved

Syntax

IsCoefficientsSaved(Coord: IMsFormulaTransformCoord): Boolean;

Parameters

Coord. Output variable slice for which coefficients are checked.

Description

The IsCoefficientsSaved property returns True if model coefficients are saved.

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 the model parameters are modified, new equation coefficients are calculated. Unsaved coefficient values are saved and displayed in the console window.

See also:

IMsLinearRegressionTransform