Learn R Programming

forecastHybrid (version 5.0.19)

forecast.hybridModel: Hybrid forecast

Description

Forecast method for hybrid models.

Usage

# S3 method for hybridModel
forecast(
  object,
  h = ifelse(object$frequency > 1, 2 * object$frequency, 10),
  xreg = NULL,
  level = c(80, 95),
  PI = TRUE,
  fan = FALSE,
  PI.combination = c("extreme", "mean"),
  ...
)

Arguments

object

a hybrid time series model fit with hybridModel.

h

number of periods for forecasting. If xreg is used, h is ignored and the number of forecast periods is set to the number of rows of xreg.

xreg

future values of regression variables (for use if one of the ensemble methods used in creating the hybrid forecast was auto.arima, nnetar, or stlm and the model(s) used xreg in the fit). It should be supplied as a matrix.

level

confidence level for prediction intervals. This can be expressed as a decimal between 0.0 and 1.0 or numeric between 0 and 100.

PI

should prediction intervals be produced? If a nnetar model is in the ensemble, this can be quite slow, so disabling prediction intervals will speed up the forecast generation. If FALSE, the arguments level and fan are ignored.

fan

if TRUE, level is set to seq(51, 99, by = 3). This is suitable for fan plots.

PI.combination

Method for combining the prediction intervals from each of the forecasts. Supplying "mean" will simply average each of the lower/upper intervals from each model without using the model weights used for the point forecasts. The default value "extreme" will take the most pessimistic intervals (i.e. the highest upper interval from all the component models and the lowest prediction interval from all of the component models').

...

other arguments passed to the individual forecast generic methods.

Value

An object of class forecast.

Details

if xreg was used in constructing the hybridModel, it must also be passed into forecast.hybridModel.

While prediction intervals are produced for the final ensemble forecast model, these should be viewed conservatively as insights to the forecast's uncertainty. Currently these are constructed using the most extreme interval from each component model for each horizon, so the composite prediction intervals do not have statistical guarantees of asymptotic efficiency. More sophisticated and rigorous techniques are planned, however, particularly when cross validation approaches are used.

See Also

hybridModel

Examples

Run this code
# NOT RUN {
mod <- hybridModel(AirPassengers)
fc <- forecast(mod)

# View the point forecasts
fc$mean

# View the upper prediction interval
fc$upper

# View the lower prediction interval
fc$lower

# Plot the forecast
plot(fc)
# }

Run the code above in your browser using DataLab