Use a model's fitted distribution to simulate additional data with similar behaviour to the response. This is a tidy implementation of \link[stats]{simulate}.

# S3 method for mdl_df
generate(x, new_data = NULL, h = NULL, times = 1, seed = NULL, ...)

# S3 method for mdl_ts
generate(x, new_data = NULL, h = NULL, times = 1, seed = NULL, ...)



A mable.


The data to be generated (time index and exogenous regressors)


The simulation horizon (can be used instead of new_data for regular time series with no exogenous regressors).


The number of replications.


The seed for the random generation from distributions.


Additional arguments for individual simulation methods.


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 for the simulated paths..


if (requireNamespace("fable", quietly = TRUE)) { library(fable) library(dplyr) UKLungDeaths <- as_tsibble(cbind(mdeaths, fdeaths), pivot_longer = FALSE) UKLungDeaths %>% model(lm = TSLM(mdeaths ~ fourier("year", K = 4) + fdeaths)) %>% generate(UKLungDeaths, times = 5) }
#> Warning: `time_unit()` is deprecated as of tsibble 0.9.0. #> Please use `default_time_units()` instead. #> This warning is displayed once per session. #> Call `lifecycle::last_warnings()` to see where this warning was generated.
#> Error: `vars` must be a character vector