IMsForecastObject.Forecast

Fore Syntax

Forecast(Period: IMsPeriod): IMsForecast;

Fore.NET Syntax

Forecast[Period: Prognoz.Platform.Interop.Ms.IMsPeriod]: Prognoz.Platform.Interop.Ms.IMsForecast;

Parameters

Period. Forecasting period.

Description

The Forecast property returns forecast series parameters.

Comments

If the Period parameter is set to Null, the forecasting period corresponds to method calculation period.

Fore Example

Custom method of calculation which returns forecast values for any forecast 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 statistics (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 statistics (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:

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Stat;

Public Shared Function ForecastVal(FO: IMsForecastObject): ITimeSeries;
Var
    SumStat: ISummaryStatistics;
    Series: ITimeSeries;
    Period: IMsDatePeriod;
    Forecast: IMsForecast;
Begin
    // Display method name
    System.Diagnostics.Debug.WriteLine("Method name: " + FO.BaseMethod.Name);
    System.Diagnostics.Debug.WriteLine("");
    // Get statistical characteristics
    SumStat := FO.Stats;
    // Display statistical characteristics to the console window
    System.Diagnostics.Debug.WriteLine("Statistical characteristics");
    System.Diagnostics.Debug.Indent();
    System.Diagnostics.Debug.WriteLine("Quality criteria");
    System.Diagnostics.Debug.Indent();
    System.Diagnostics.Debug.WriteLine("Determination coefficient (R^2): " + SumStat.R2.ToString());
    System.Diagnostics.Debug.WriteLine("Adjusted determination coefficient (adj R^2): " + SumStat.AdjR2.ToString());
    System.Diagnostics.Debug.WriteLine("Fisher statistics (F): " + SumStat.Fstat.ToString());
    System.Diagnostics.Debug.WriteLine("Fisher statistic probability (p-v): " + SumStat.ProbFstat.ToString());
    System.Diagnostics.Debug.Unindent();
    System.Diagnostics.Debug.WriteLine("Diagnostic criteria");
    System.Diagnostics.Debug.Indent();
    System.Diagnostics.Debug.WriteLine("Durbin-Watson statistics (DW): " + SumStat.DW.ToString());
    System.Diagnostics.Debug.Unindent();
    System.Diagnostics.Debug.Unindent();
    System.Diagnostics.Debug.WriteLine("");
    // Get modeling series and display it in the console window
    Series := FO.Fitted;
    System.Diagnostics.Debug.WriteLine("Modeling series");
    Print(Series);
    // Get residual series and display it in the console window
    Series := FO.Residuals;
    System.Diagnostics.Debug.WriteLine("Residuals series");
    Print(Series);
    // Get output series and display it in the console window
    Series := FO.TimeSeries;
    System.Diagnostics.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;
    System.Diagnostics.Debug.WriteLine("Forecast series");
    Print(Series);
    // Get and display values of forecast series upper confidence limit to the console window
    Series := Forecast.UpperConfidenceLevel;
    System.Diagnostics.Debug.WriteLine("Values of forecast series upper confidence limit");
    Print(Series);
    // Get and display values of forecast series lower confidence limit
    Series := Forecast.LowerConfidenceLevel;
    System.Diagnostics.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;
    System.Diagnostics.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;
    System.Diagnostics.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;
    System.Diagnostics.Debug.WriteLine("Values of the series including 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
Public Shared Sub Print(Series: ITimeSeries);
Var
    CultureInfo: CultureInfoClassClass = New CultureInfoClassClass();
    i: Integer;
    d: DateTime;
Begin
    System.Diagnostics.Debug.Indent();
    For i := Series.StartIndex To Series.EndIndex Do
        d := Series.IndexToDate(i);
        System.Diagnostics.Debug.WriteLine(CultureInfo.Current.FormatShortDate(d) + ": " + Series.Item[i]);
    End For;
    System.Diagnostics.Debug.Unindent();
    System.Diagnostics.Debug.WriteLine("");
End Sub Print;

See also:

IMsForecastObject