StatCoefficientsByIndex(Coord: IMsFormulaTransformCoord;
Index: Integer): ISlConstCoefficients;
StatCoefficientsByIndex[Coord: Prognoz.Platform.Interop.Ms.IMsFormulaTransformCoord;
Index: Integer]: Prognoz.Platform.Interop.Stat.ISlConstCoefficients;
Coord. The output variable slice for which calculation is performed.
Index. Coefficient index.
The StatCoefficientsByIndex property returns the values of summary statistics calculated for coefficients of the identified model equation by coefficient index.
To get coefficient array, use the IMsNonLinearRegressionTransform.Coefficients property.
Executing the example requires that the repository contains a modeling container with the MS identifier containing a model with the MODEL_NONLINEAR identifier calculated by the Non-Linear Regression (Non-Linear Least-Squares Method Estimation) method.
Add links to the Metabase, Ms, Stat system assemblies.
Sub UserProc;
Var
mb: IMetabase;
MsKey: Integer;
Model: IMsModel;
Transform: IMsFormulaTransform;
NonLinear: IMsNonLinearRegressionTransform;
Calc: IMsModelCalculation;
OutputVar: IMsFormulaTransformVariable;
Coord: IMsFormulaTransformCoord;
CoefData: Array Of Double;
Coef: Array Of String;
j: Integer;
ConstCoeff: ISlConstCoefficients;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get the model
Model := mb.ItemByIdNamespace("MODEL_NONLINEAR", MsKey).Edit As IMsModel;
// Get model parameters
Transform := Model.Transform;
// Get calculation method parameters
NonLinear := Transform.FormulaItem(0).Method As IMsNonLinearRegressionTransform;
// Set significance of confidence limits
NonLinear.ConfidenceLevel := 0.90;
// Add a new coefficient to model equation
NonLinear.Expression.AsString := "(" + NonLinear.Expression.AsString + ") * A1";
// Create model calculation settings
Calc := Model.CreateCalculation;
// Set calculation periods
Calc.Period.IdentificationStartDate := DateTime.Parse("01.01.1990");
Calc.Period.IdentificationEndDate := DateTime.Parse("01.01.2010");
Calc.Period.ForecastStartDate := DateTime.Parse("01.01.2011");
Calc.Period.ForecastEndDate := DateTime.Parse("01.01.2017");
// Get output variable
OutputVar := Transform.Outputs.Item(0);
// Get output variable parameters required for model calculation
Coord := Transform.CreateCoord(OutputVar);
// Identify model coefficients
NonLinear.Identify(Calc As IMsMethodCalculation, Coord);
// Get identified coefficients
CoefData := NonLinear.CoefficientsData(Coord);
// Get coefficient names
Coef := NonLinear.Coefficients;
// Output names, values and summary statistics of coefficients in the console window
Debug.WriteLine("Values and standard coefficient error");
For j := 0 To CoefData.Length - 1 Do
// Output name, value of coefficient
Debug.Write(" " + Coef[j] + ": " + CoefData[j].ToString);
// Get summary statistics of coefficient
ConstCoeff := NonLinear.StatCoefficientsByIndex(Coord, j);
// Output standard coefficient error
Debug.WriteLine("; " + ConstCoeff.StandardError.ToString);
End For;
// Save changes in the model
(Model As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the model parameters are changed, the console window will display values and standard coefficient error of the model.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Stat;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
MsKey: uinteger;
Model: IMsModel;
Transform: IMsFormulaTransform;
NonLinear: IMsNonLinearRegressionTransform;
Calc: IMsModelCalculation;
OutputVar: IMsFormulaTransformVariable;
Coord: IMsFormulaTransformCoord;
CoefData: System.Array;
Coef: System.Array;
j: Integer;
ConstCoeff: ISlConstCoefficients;
Begin
// Get current repository
mb := Params.Metabase;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get the model
Model := mb.ItemByIdNamespace["MODEL_NONLINEAR", MsKey].Edit() As IMsModel;
// Get model parameters
Transform := Model.Transform;
// Get calculation method parameters
NonLinear := Transform.FormulaItem[0].Method As IMsNonLinearRegressionTransform;
// Set significance of confidence limits
NonLinear.ConfidenceLevel := 0.90;
// Add a new coefficient to model equation
NonLinear.Expression.AsString := "(" + NonLinear.Expression.AsString + ") * A1";
// Create model calculation settings
Calc := Model.CreateCalculation();
// Set calculation periods
Calc.Period.IdentificationStartDate := DateTime.Parse("01.01.1990");
Calc.Period.IdentificationEndDate := DateTime.Parse("01.01.2010");
Calc.Period.ForecastStartDate := DateTime.Parse("01.01.2011");
Calc.Period.ForecastEndDate := DateTime.Parse("01.01.2017");
// Get output variable
OutputVar := Transform.Outputs.Item[0];
// Get output variable parameters required for model calculation
Coord := Transform.CreateCoord(OutputVar);
// Identify model coefficients
NonLinear.Identify(Calc As IMsMethodCalculation, Coord);
// Get identified coefficients
CoefData := NonLinear.CoefficientsData[Coord];
// Get coefficient names
Coef := NonLinear.Coefficients;
// Output names, values and summary statistics of coefficients in the console window
System.Diagnostics.Debug.WriteLine("Values and standard coefficient error");
For j := 0 To CoefData.Length - 1 Do
// Output name, value of coefficient
System.Diagnostics.Debug.Write(" " + Coef[j] + ": " + CoefData[j].ToString());
// Get summary statistics of coefficient
ConstCoeff := NonLinear.StatCoefficientsByIndex[Coord, j];
// Output standard coefficient error
System.Diagnostics.Debug.WriteLine("; " + ConstCoeff.StandardError.ToString());
End For;
// Save changes in the model
(Model As IMetabaseObject).Save();
End Sub;
See also: