IMsForecastObject.Forecast

Syntax

Forecast(Period: IMsPeriod): IMsForecast;

Parameters

Period. Forecasting period.

Description

The Forecast property returns forecast series parameters.

Comments

If this Period parameter is set to Null, the forecasting period will match with the method calculation period.

Example

A custom method of calculation that returns forecasting values for any forecasting calculation method is given.

Add links to the Ms, Stat system assemblies.

Public Function ForecastVal(FO: IMsForecastObject): ITimeSeries;
Var
    SumStat: ISummaryStatistics;
    Series: ITimeSeries;
    Period: IMsDatePeriod;
    Forecast: IMsForecast;
Begin
    // Display method name
    Debug.WriteLine("Method name: " + FO.BaseMethod.Name);
    Debug.WriteLine("");
    // Get statistical characteristics
    SumStat := FO.Stats;
    // Display statistical characteristics to the console window
    Debug.WriteLine("Statistical characteristics");
    Debug.Indent;
    Debug.WriteLine("Quality criteria");
    Debug.Indent;
    Debug.WriteLine("Determination coefficient (R^2): " + SumStat.R2.ToString);
    Debug.WriteLine("Adjusted determination coefficient (adj R^2): " + SumStat.AdjR2.ToString);
    Debug.WriteLine("Fisher statistic (F): " + SumStat.Fstat.ToString);
    Debug.WriteLine("Fisher statistic probability (p-v): " + SumStat.ProbFstat.ToString);
    Debug.Unindent;
    Debug.WriteLine("Diagnostic criteria");
    Debug.Indent;
    Debug.WriteLine("Durbin-Watson statistic (DW): " + SumStat.DW.ToString);
    Debug.Unindent;
    Debug.Unindent;
    Debug.WriteLine("");
    // Get modeling series and display it in the console window
    Series := FO.Fitted;
    Debug.WriteLine("Modeling series");
    Print(Series);
    // Get residual series and display it in the console window
    Series := FO.Residuals;
    Debug.WriteLine("Residuals series");
    Print(Series);
    // Get output series and display it in the console window
    Series := FO.TimeSeries;
    Debug.WriteLine("Output series");
    Print(Series);
    // Create time period
    Period := New MsDatePeriod.Create;
    Period.Start := DateTime.Parse("01.01.2010");
    Period.End_ := DateTime.Parse("31.12.2020");
    // Get forecast series parameters for selected period
    Forecast := FO.Forecast(Period);
    // Get and display forecast series values to the console window
    Series := Forecast.Value;
    Debug.WriteLine("Forecast series");
    Print(Series);
    // Get and display values of forecast series upper confidence limit to the console window
    Series := Forecast.UpperConfidenceLevel;
    Debug.WriteLine("Values of forecast series upper confidence limit");
    Print(Series);
    // Get and display values of forecast series lower confidence limit
    Series := Forecast.LowerConfidenceLevel;
    Debug.WriteLine("Values of forecast series lower confidence limit");
    Print(Series);
    // Get and display upper dynamic confidence limit values of forecast series
    Series := Forecast.DynamicUpperConfidenceLevel;
    Debug.WriteLine("Upper dynamic confidence limit values of forecast series;
    Print(Series);
    // Get and display lower dynamic confidence limit values of forecast series
    Series := Forecast.DynamicLowerConfidenceLevel;
    Debug.WriteLine("Lower dynamic confidence limit values of forecast series");
    Print(Series);
    // Get and display values of the series
    // containing data of source series at sample period and of forecasting series at forecasting period in the console window
    Series := Forecast.Combined;
    Debug.WriteLine("Values of the series containing initial series data at identification period " +
        "and forecasting series at forecasting period");
    Print(Series);
    // Return forecasting series
    Return Forecast.Value;
End Function ForecastVal;

// Procedure of series values displaying in the console window
Sub Print(Series: ITimeSeries);
Var
    i: Integer;
    d: DateTime;
Begin
    Debug.Indent;
    For i := Series.StartIndex To Series.EndIndex Do
        d := Series.IndexToDate(i);
        Debug.WriteLine(CultureInfo.Current.FormatShortDate(d) + ": " + Series.Item(i));
    End For;
    Debug.Unindent;
    Debug.WriteLine("");
End Sub Print;

After executing the example the console window displays:

This custom method can be used in determinate equation , in calculator   in time series analysis and in expression editor. For example, the use of custom method in determinate equation:

IMsForecastObject_Forecast.ForecastVal(Arima(X1, Null, "1", "1", 1, 2))

Where:

See also:

IMsForecastObject