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 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 4 [1M]
#> # Key:       .model, .rep [1]
#>    .model .rep     index   .sim
#>    <chr>  <chr>    <mth>  <dbl>
#>  1 lm     1     1979 Jan  7607.
#>  2 lm     1     1979 Feb  6645.
#>  3 lm     1     1979 Mar  7800.
#>  4 lm     1     1979 Apr  7849.
#>  5 lm     1     1979 May  8109.
#>  6 lm     1     1979 Jun  9329.
#>  7 lm     1     1979 Jul 10041.
#>  8 lm     1     1979 Aug  9034.
#>  9 lm     1     1979 Sep  7585.
#> 10 lm     1     1979 Oct  8631.
#> # ℹ 14 more rows