ObservationsCount(Calculation: IMsMethodCalculation; Coord: IMsFormulaTransformCoord): Integer;
Calculation. Model calculation options.
Coord. Output variable slice, for which calculation is executed.
The ObservationsCount property returns the number of model observations.
The general number of observation is determines the by the period of model identification. The IMsModelPeriod interface is used to set it up.
ObservationsCount considers not only the sample period, but also the lag, autoregression and model transformation order.
Executing the example requires that the repository contains a modeling container with the CONT_MODEL identifier. The container includes a model with the MODEL identifier.
Add links to the Metabase, Ms system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Model: IMsModel;
Transform: IMsFormulaTransform;
VarTrans: IMsFormulaTransformVariable;
Tree: IMsFormulaTransformSlicesTree;
Slice: IMsFormulaTransformSlice;
Selector: IMsFormulaTransformSelector;
Formula: IMsFormula;
Method: IMsMethod;
Coord: IMsFormulaTransformCoord;
Calc: IMsModelCalculation;
ObsCount: Integer;
Begin
MB := MetabaseClass.Active;
Model := MB.ItemByIdNamespace("MODEL", MB.ItemById("CONT_MODEL").Key).Bind As IMsModel;
Transform := Model.Transform;
VarTrans := Transform.Outputs.Item(0);
Tree := VarTrans.SlicesTree(VarTrans);
Slice := Tree.CreateSlice(1);
Selector := Transform.CreateSelector;
Selector.Slice := Slice;
Formula := Transform.Transform(Selector);
Method := Formula.Method;
Coord := Transform.CreateCoord(VarTrans);
Calc := Model.CreateCalculation;
Calc.Period.IdentificationStartDate := DateTime.ComposeDay(2000, 01, 01);
Calc.Period.IdentificationEndDate := DateTime.ComposeDay(2005, 12, 31);
Calc.Period.ForecastStartDate := DateTime.ComposeDay(2006, 01, 01);
Calc.Period.ForecastEndDate := DateTime.ComposeDay(2010, 12, 31);
ObsCount := Method.ObservationsCount(Calc As IMsMethodCalculation, Coord);
Debug.WriteLine(Number of observations: + ObsCount.ToString);
End Sub UserProc;
After executing the example, the number of model observations at the specified sample period is displayed in the console window.
See also: