B1Result: Array;
B1Result: System.Array;
The B1Result property returns a prior adjusted series or source series.
The value is available only after method calculation. To set the term, to which these results will be loaded, use the IMsCensus2Transform.B1Term property.
Executing the example requires that the repository contains a modeling container with the MODEL_SPACE identifier containing a model with the MODEL_CENSUS2 identifier. The model must be calculated by the X11 method.
Add links to the Metabase, Ms system assemblies.
Sub X11;
Var
mb: IMetabase;
MsObj: IMetabaseObjectDescriptor;
Model: IMsModel;
Transform: IMsFormulaTransform;
Vars: IMsFormulaTransformVariables;
OutputVar: IMsFormulaTransformVariable;
Coord: IMsFormulaTransformCoord;
Formula: IMsFormula;
Census2: IMsCensus2Transform;
Calc: IMsMethodCalculation;
Data: Array Of Double;
Begin
mb := MetabaseClass.Active;
// Get modeling container
MsObj := mb.ItemById("MODEL_SPACE");
// Get model
Model := mb.ItemByIdNamespace("MODEL_CENSUS2", MsObj.Key).Edit As IMsModel;
// Get model parameters
Transform := Model.Transform;
// Get parameters of X11 method calculation
Formula := Transform.FormulaItem(0);
Census2 := Formula.Method As IMsCensus2Transform;
// Set component unloaded to output variable
Census2.OutputType := MsCensus2OutputType.D11;
// Set up model calculation
Vars := Transform.Outputs;
OutputVar := Vars.Item(0);
Coord := Transform.CreateCoord(OutputVar);
// Set calculation period parameters
Calc := Transform.CreateCalculation;
Calc.Period.IdentificationStartDate := model.Period.IdentificationStartDate;
Calc.Period.IdentificationEndDate := model.Period.IdentificationEndDate;
Calc.Period.ForecastStartDate := model.Period.ForecastStartDate;
Calc.Period.ForecastEndDate := model.Period.ForecastEndDate;
// Execute calculation
Census2.Execute(Calc, Coord);
// Display calculation results
Data := Census2.Explained.Serie(Calc);
Debug.WriteLine("Modeled data");
Print(Data); Debug.WriteLine("");
Data := Census2.B1Result;
Debug.WriteLine("Prior adjusted series or source series");
Print(Data); Debug.WriteLine("");
Data := Census2.D10Result;
Debug.WriteLine("Seasonal component");
Print(Data); Debug.WriteLine("");
Data := Census2.D11Result;
Debug.WriteLine("Seasonal adjustment");
Print(Data); Debug.WriteLine("");
Data := Census2.D12Result;
Debug.WriteLine("Trend-cycle component");
Print(Data); Debug.WriteLine("");
Data := Census2.D13Result;
Debug.WriteLine("Irregular component");
Print(Data); Debug.WriteLine("");
// Save model
(Model As IMetabaseObject).Save;
End Sub X11;
// Data output procedure
Sub Print(Data: Array Of Double);
Var
i: Integer;
Begin
Debug.Indent;
For i := 0 To Data.Length - 1 Do
Debug.WriteLine(i.ToString + " " + Data[i].ToString);
End For;
Debug.Unindent;
End Sub Print;
Example execution result: the model is calculated by the X11 method, calculation results are 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;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
MsObj: IMetabaseObjectDescriptor;
Model: IMsModel;
Transform: IMsFormulaTransform;
Vars: IMsFormulaTransformVariables;
OutputVar: IMsFormulaTransformVariable;
Coord: IMsFormulaTransformCoord;
Formula: IMsFormula;
Census2: IMsCensus2Transform;
Calc: IMsMethodCalculation;
Data: System.Array;
Begin
mb := Params.Metabase;
// Get modeling container
MsObj := mb.ItemById["MODEL_SPACE"];
// Get model
Model := mb.ItemByIdNamespace["MODEL_CENSUS2", MsObj.Key].Edit() As IMsModel;
// Get model parameters
Transform := Model.Transform;
// Get parameters of X11 method calculation
Formula := Transform.FormulaItem[0];
Census2 := Formula.Method As IMsCensus2Transform;
// Set component unloaded to output variable
Census2.OutputType := MsCensus2OutputType.mcotD11;
// Set up model calculation
Vars := Transform.Outputs;
OutputVar := Vars.Item[0];
Coord := Transform.CreateCoord(OutputVar);
// Set calculation period parameters
Calc := Transform.CreateCalculation();
Calc.Period.IdentificationStartDate := model.Period.IdentificationStartDate;
Calc.Period.IdentificationEndDate := model.Period.IdentificationEndDate;
Calc.Period.ForecastStartDate := model.Period.ForecastStartDate;
Calc.Period.ForecastEndDate := model.Period.ForecastEndDate;
// Execute calculation
Census2.Execute(Calc, Coord);
// Display calculation results
Data := Census2.Explained.Serie[Calc];
System.Diagnostics.Debug.WriteLine("Modeled data");
Print(Data); System.Diagnostics.Debug.WriteLine("");
Data := Census2.B1Result;
System.Diagnostics.Debug.WriteLine("Prior adjusted series or source series");
Print(Data); System.Diagnostics.Debug.WriteLine("");
Data := Census2.D10Result;
System.Diagnostics.Debug.WriteLine("Seasonal component");
Print(Data); System.Diagnostics.Debug.WriteLine("");
Data := Census2.D11Result;
System.Diagnostics.Debug.WriteLine("Seasonal adjustment");
Print(Data); System.Diagnostics.Debug.WriteLine("");
Data := Census2.D12Result;
System.Diagnostics.Debug.WriteLine("Trend-cycle component");
Print(Data); System.Diagnostics.Debug.WriteLine("");
Data := Census2.D13Result;
System.Diagnostics.Debug.WriteLine("Irregular component");
Print(Data); System.Diagnostics.Debug.WriteLine("");
// Save the model
(Model As IMetabaseObject).Save();
End Sub;
// Data output procedure
Public Shared Sub Print(Data: System.Array);
Var
i: Integer;
Begin
System.Diagnostics.Debug.Indent();
For i := 0 To Data.Length - 1 Do
System.Diagnostics.Debug.WriteLine(i.ToString() + " " + Data[i].ToString());
End For;
System.Diagnostics.Debug.Unindent();
End Sub Print;
See also: