Produces forecasts from a trained model.

# S3 method for RW
forecast(
  object,
  new_data,
  specials = NULL,
  simulate = FALSE,
  bootstrap = FALSE,
  times = 5000,
  ...
)

Arguments

object

A model for which forecasts are required.

new_data

A tsibble containing the time points and exogenous regressors to produce forecasts for.

specials

(passed by fabletools::forecast.mdl_df()).

simulate

If TRUE, prediction intervals are produced by simulation rather than using analytic formulae.

bootstrap

If TRUE, then forecast distributions are computed using simulation with resampled errors.

times

The number of sample paths to use in estimating the forecast distribution when bootstrap = TRUE.

...

Other arguments passed to methods

Value

A list of forecasts.

Examples

as_tsibble(Nile) %>%
  model(NAIVE(value)) %>%
  forecast()
#> # A fable: 2 x 4 [1Y]
#> # Key:     .model [1]
#>   .model       index         value .mean
#>   <chr>        <dbl>        <dist> <dbl>
#> 1 NAIVE(value)  1971 N(740, 27998)   740
#> 2 NAIVE(value)  1972 N(740, 55995)   740

library(tsibbledata)
aus_production %>%
  model(snaive = SNAIVE(Beer ~ lag("year"))) %>%
  forecast()
#> # A fable: 8 x 4 [1Q]
#> # Key:     .model [1]
#>   .model Quarter        Beer .mean
#>   <chr>    <qtr>      <dist> <dbl>
#> 1 snaive 2010 Q3 N(419, 373)   419
#> 2 snaive 2010 Q4 N(488, 373)   488
#> 3 snaive 2011 Q1 N(414, 373)   414
#> 4 snaive 2011 Q2 N(374, 373)   374
#> 5 snaive 2011 Q3 N(419, 747)   419
#> 6 snaive 2011 Q4 N(488, 747)   488
#> 7 snaive 2012 Q1 N(414, 747)   414
#> 8 snaive 2012 Q2 N(374, 747)   374