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 'TSLM'
generate(x, new_data, specials, bootstrap = FALSE, ...)

Arguments

x

A fitted model.

new_data

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

specials

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

bootstrap

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

...

Other arguments passed to methods

Examples

as_tsibble(USAccDeaths) %>%
  model(lm = TSLM(log(value) ~ trend() + season())) %>%
  generate()
#> # A tsibble: 24 x 3 [1M]
#> # Key:       .model [1]
#>    .model    index   .sim
#>    <chr>     <mth>  <dbl>
#>  1 lm     1979 Jan  8641.
#>  2 lm     1979 Feb  7267.
#>  3 lm     1979 Mar  7193.
#>  4 lm     1979 Apr  8260.
#>  5 lm     1979 May  8655.
#>  6 lm     1979 Jun  8968.
#>  7 lm     1979 Jul 10373.
#>  8 lm     1979 Aug  9256.
#>  9 lm     1979 Sep  8500.
#> 10 lm     1979 Oct  8165.
#> # ℹ 14 more rows