Simulates future paths from a dataset using a fitted model. Innovations are sampled by the model's assumed error distribution. If bootstrap is TRUE, innovations will be sampled from the model's residuals. If new_data contains the .innov column, those values will be treated as innovations.

# S3 method for class 'RW'
generate(x, new_data, bootstrap = FALSE, ...)

Arguments

x

A fitted model.

new_data

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

bootstrap

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

...

Other arguments passed to methods

Examples

as_tsibble(Nile) %>%
  model(NAIVE(value)) %>%
  generate()
#> # A tsibble: 2 x 4 [1Y]
#> # Key:       .model, .rep [1]
#>   .model       index .rep   .sim
#>   <chr>        <dbl> <chr> <dbl>
#> 1 NAIVE(value)  1971 1     1170.
#> 2 NAIVE(value)  1972 1     1350.

library(tsibbledata)
aus_production %>%
  model(snaive = SNAIVE(Beer ~ lag("year"))) %>%
  generate()
#> # A tsibble: 8 x 4 [1Q]
#> # Key:       .model, .rep [1]
#>   .model Quarter .rep   .sim
#>   <chr>    <qtr> <chr> <dbl>
#> 1 snaive 2010 Q3 1      396.
#> 2 snaive 2010 Q4 1      509.
#> 3 snaive 2011 Q1 1      415.
#> 4 snaive 2011 Q2 1      370.
#> 5 snaive 2011 Q3 1      415.
#> 6 snaive 2011 Q4 1      510.
#> 7 snaive 2012 Q1 1      428.
#> 8 snaive 2012 Q2 1      354.