Result: IMsFormulaTerm;
Result: Prognoz.Platform.Interop.Ms.IMsFormulaTerm;
The Result property returns the term corresponding to output variable.
To get exogenous variables, use the IMsCointegrationEquationTransform.Operands property.
Executing the example requires that the repository contains a modeling parameter with the MS identifier containing an error correction model with the MODEL_COINTEGRATIONEQ identifier.
Add links to the Metabase, Ms, Stat system assemblies.
Sub UserProc;
Var
mb: IMetabase;
ModelCont: IMetabaseObjectDescriptor;
Model: IMsModel;
Transform: IMsFormulaTransform;
Formula: IMsFormula;
Eq: IMsCointegrationEquationTransform;
i: integer;
Calc: IMsMethodCalculation;
arr: Array Of Double;
Period: IMsModelPeriod;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get modeling container
ModelCont := mb.ItemById("MS");
// Get error correction model
Model := mb.ItemByIdNamespace("MODEL_COINTEGRATIONEQ", ModelCont.Key).Edit As IMsModel;
// Get model parameters
Transform := Model.Transform;
Formula := Transform.FormulaItem(0);
Eq := Formula.Method As IMsCointegrationEquationTransform;
// Set type of error correction model
Eq.ModelType := ECMType.NoTrendIntercept;
// Set autoregression order of endogenous and exogenous variables
Eq.EndogenousAutoRegressionOrder[0] := 1;
Eq.ExogenousAutoRegressionOrder[0] := 0;
// Select missing data treatment method
Eq.MissingData.Method := MissingDataMethod.Geometric;
// Set significance of confidence levels
Eq.ConfidenceLevel := 0.2;
// Include all variables to the group describing short-term cointegration relations
For i := 0 To Eq.Operands.Count - 1 Do
Eq.OperandType(i) := MsCointegrationEquationOperandType.Common;
End For;
// Create an object with model calculation parameters
Calc := Transform.CreateCalculation;
// Set calculation periods
Period := Model.Transform.Period;
Calc.Period.IdentificationStartDate := Period.IdentificationStartDate;
Calc.Period.IdentificationEndDate := Period.IdentificationEndDate;
Calc.Period.ForecastStartDate := Period.ForecastStartDate;
Calc.Period.ForecastEndDate := Period.ForecastEndDate;
Calc.CurrentPoint := Period.IdentificationStartDate;
// Get output variable data and display it in the console window
arr := Eq.Result.Serie(Calc);
For i := 0 To arr.Length - 1 Do
Debug.WriteLine(arr[i]);
End For;
(Model As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the model parameters are changed, all exogenous variables are included into the group describing short-term cointegration relations, output variable data is displayed in the console window.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Stat;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
ModelCont: IMetabaseObjectDescriptor;
Model: IMsModel;
Transform: IMsFormulaTransform;
Formula: IMsFormula;
Eq: IMsCointegrationEquationTransform;
i: integer;
Calc: IMsMethodCalculation;
arr: System.Array;
Period: IMsModelPeriod;
Begin
// Get current repository
mb := Params.Metabase;
// Get modeling container
ModelCont := mb.ItemById["MS"];
// Get error correction model
Model := mb.ItemByIdNamespace["MODEL_COINTEGRATIONEQ", ModelCont.Key].Edit() As IMsModel;
// Get model parameters
Transform := Model.Transform;
Formula := Transform.FormulaItem[0];
Eq := Formula.Method As IMsCointegrationEquationTransform;
// Set type of error correction model
Eq.ModelType := ECMType.ecmtNoTrendIntercept;
// Set autoregression order of endogenous and exogenous variables
Eq.EndogenousAutoRegressionOrder.SetValue(1, 0);
Eq.ExogenousAutoRegressionOrder.SetValue(0, 0);
// Set missing data treatment method
Eq.MissingData.Method := MissingDataMethod.mdmGeometric;
// Set significance of confidence limits
Eq.ConfidenceLevel := 0.2;
// Include all variables to the group describing short-term cointegration relations
For i := 0 To Eq.Operands.Count - 1 Do
Eq.OperandType[i] := MsCointegrationEquationOperandType.mceotCommon;
End For;
// Create an object with model calculation parameters
Calc := Transform.CreateCalculation();
// Set calculation periods
Period := Model.Transform.Period;
Calc.Period.IdentificationStartDate := Period.IdentificationStartDate;
Calc.Period.IdentificationEndDate := Period.IdentificationEndDate;
Calc.Period.ForecastStartDate := Period.ForecastStartDate;
Calc.Period.ForecastEndDate := Period.ForecastEndDate;
Calc.CurrentPoint := Period.IdentificationStartDate;
// Get output variable data and display it in the console window
arr := Eq.Result.Serie[Calc];
For i := 0 To arr.Length - 1 Do
System.Diagnostics.Debug.WriteLine(arr[i]);
End For;
(Model As IMetabaseObject).Save();
End Sub;
See also: