CalculateSeries(
Calculation: IMsMethodCalculation;
Coord: IMsFormulaTransformCoord): IMsTransformSeries;
CalculateSeries[
Calculation: Prognoz.Platform.Interop.Ms.IMsMethodCalculation;
Coord: Prognoz.Platform.Interop.Ms.IMsFormulaTransformCoord]: Prognoz.Platform.Interop.Ms.IMsTransformSeries;
Calculation. Model calculation parameters.
Coord. Output variable slice for which calculation is performed.
The CalculateSeries property returns results of model calculation.
This method allows to receive the results of model calculation without calculation of the whole problem.
Models available for the method
Executing the example requires that repository contains a modeling container with the MS identifier. The container includes a model with the MODEL_LINREG identifier. The model uses the method of linear regression (OLS estimation) for calculation.
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;
LinReg: IMsLinearRegressionTransform;
Coord: IMsFormulaTransformCoord;
Calc: IMsModelCalculation;
CalcRes: IMsTransformSeries;
d: Double;
Begin
// Get current repository
MB := MetabaseClass.Active;
// Get model
Model := MB.ItemByIdNamespace("MODEL_LINREG", MB.ItemById("MS").Key).Bind As IMsModel;
// Get model parameters
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);
LinReg := Formula.Method As IMsLinearRegressionTransform;
Coord := Transform.CreateCoord(VarTrans);
// Create object to calculate model
Calc := Model.CreateCalculation;
// Set calculation periods
Calc.Period.IdentificationStartDate := DateTime.Parse("01.01.2000");
Calc.Period.IdentificationEndDate := DateTime.Parse("31.12.2005");
Calc.Period.ForecastStartDate := DateTime.Parse("01.01.2006");
Calc.Period.ForecastEndDate := DateTime.Parse("31.12.2010");
// Perform calculation
CalcRes := LinReg.CalculateSeries(Calc As IMsMethodCalculation, Coord);
// Display calculation results to console window
Debug.WriteLine("Initial series:");
For Each d In CalcRes.Fact Do
Debug.WriteLine(d.ToString);
End For;
Debug.WriteLine("");
Debug.WriteLine("Modeling series:");
For Each d In CalcRes.Modelling Do
Debug.WriteLine(d.ToString);
End For;
Debug.WriteLine("");
Debug.WriteLine("Rest:");
For Each d In CalcRes.Residuals Do
Debug.WriteLine(d.ToString);
End For;
Debug.WriteLine("");
Debug.WriteLine("Forecast:");
For Each d In CalcRes.Forecast Do
Debug.WriteLine(d.ToString);
End For;
Debug.WriteLine("");
Debug.WriteLine("Upper confidence limit:");
For Each d In CalcRes.UpperConfidenceLevel Do
Debug.WriteLine(d.ToString);
End For;
Debug.WriteLine("");
Debug.WriteLine("Lower confidence limit:");
For Each d In CalcRes.LowerConfidenceLevel Do
Debug.WriteLine(d.ToString);
End For;
End Sub UserProc;
After executing the example the model is calculated. Data of initial, output, forecast series and series with the excesses and lower and upper confidence limits are displayed in the development environment console.
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;
Model: IMsModel;
Transform: IMsFormulaTransform;
VarTrans: IMsFormulaTransformVariable;
Tree: IMsFormulaTransformSlicesTree;
Slice: IMsFormulaTransformSlice;
Selector: IMsFormulaTransformSelector;
Formula: IMsFormula;
LinReg: IMsLinearRegressionTransform;
Coord: IMsFormulaTransformCoord;
Calc: IMsModelCalculation;
CalcRes: IMsTransformSeries;
d: Double;
Begin
// Get current repository
MB := Params.Metabase;
// Get model
Model := MB.ItemByIdNamespace["MODEL_LINREG", MB.ItemById["MS"].Key].Bind() As IMsModel;
// Get model parameters
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];
LinReg := Formula.Method As IMsLinearRegressionTransform;
Coord := Transform.CreateCoord(VarTrans);
// Create object to calculate model
Calc := Model.CreateCalculation();
// Set calculation periods
Calc.Period.IdentificationStartDate := DateTime.Parse("01.01.2000");
Calc.Period.IdentificationEndDate := DateTime.Parse("31.12.2005");
Calc.Period.ForecastStartDate := DateTime.Parse("01.01.2006");
Calc.Period.ForecastEndDate := DateTime.Parse("31.12.2010");
// Recalculate
CalcRes := LinReg.CalculateSeries[Calc As IMsMethodCalculation, Coord];
// Display calculation results to the console window
System.Diagnostics.Debug.WriteLine("Initial series:");
For Each d In CalcRes.Fact Do
System.Diagnostics.Debug.WriteLine(d.ToString());
End For;
System.Diagnostics.Debug.WriteLine("");
System.Diagnostics.Debug.WriteLine("Modeling series:");
For Each d In CalcRes.Modelling Do
System.Diagnostics.Debug.WriteLine(d.ToString());
End For;
System.Diagnostics.Debug.WriteLine("");
System.Diagnostics.Debug.WriteLine("Rest:");
For Each d In CalcRes.Residuals Do
System.Diagnostics.Debug.WriteLine(d.ToString());
End For;
System.Diagnostics.Debug.WriteLine("");
System.Diagnostics.Debug.WriteLine("Forecast:");
For Each d In CalcRes.Forecast Do
System.Diagnostics.Debug.WriteLine(d.ToString());
End For;
System.Diagnostics.Debug.WriteLine("");
System.Diagnostics.Debug.WriteLine("Upper confidence limit:");
For Each d In CalcRes.UpperConfidenceLevel Do
System.Diagnostics.Debug.WriteLine(d.ToString());
End For;
System.Diagnostics.Debug.WriteLine("");
System.Diagnostics.Debug.WriteLine("Lower confidence limit:");
For Each d In CalcRes.LowerConfidenceLevel Do
System.Diagnostics.Debug.WriteLine(d.ToString());
End For;
End Sub;
See also: