Show contents 

Ms > Ms Assembly Interfaces > IMsMethod > IMsMethod.CalculateSeries

IMsMethod.CalculateSeries

Syntax

CalculateSeries(Calculation: IMsMethodCalculation; Coord: IMsFormulaTransformCoord): IMsTransformSeries;

Parameters

Calculation. Model calculation parameters.

Coord. Output variable slice for which calculation is performed.

Description

The CalculateSeries property returns results of model calculation.

Comments

This method allows to receive the results of model calculation without calculation of the whole problem.

Models available for the method

Example

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 the 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 an object for model calculation
    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");

    // Execute calculation
    CalcRes := LinReg.CalculateSeries(Calc As IMsMethodCalculation, Coord);
    // Display calculation results in the console window
    Debug.WriteLine("Source 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("Residuals:");
    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.

See also:

IMsMethod