Use a fitted model to simulate future data with similar behaviour to the response.
Usage
# S3 method for class 'mdl_vtl_df'
generate(x, new_data = NULL, h = NULL, bootstrap = FALSE, times = 1, ...)
Arguments
- x
A mable.
- new_data
Future data needed for generation (should include the time index and exogenous regressors)
- h
The simulation horizon (can be used instead of
new_data
for regular time series with no exogenous regressors).- bootstrap
If
TRUE
, then forecast distributions are computed using simulation with resampled errors.- times
The number of replications.
- ...
Additional arguments
Details
Innovations are sampled by the model's assumed error distribution.
If bootstrap
is TRUE
, innovations will be sampled from the model's residuals.
Examples
aus_mortality |>
dplyr::filter(State == "Victoria") |>
model(lc = LC(Mortality)) |>
generate(times = 3, bootstrap = TRUE)
#> Warning: 3 errors (1 unique) encountered for lc
#> [3] Lee-Carter models require a log transformation of the response variable.
#> # A vital: 1,818 x 8 [1Y]
#> # Key: Age x (Sex, State, Code, .model, .rep) [101 x 9]
#> Year Age Sex State Code .model .rep .sim
#> <dbl> <int> <chr> <chr> <chr> <chr> <chr> <dbl>
#> 1 2021 0 female Victoria VIC lc 1 NA
#> 2 2021 1 female Victoria VIC lc 1 NA
#> 3 2021 2 female Victoria VIC lc 1 NA
#> 4 2021 3 female Victoria VIC lc 1 NA
#> 5 2021 4 female Victoria VIC lc 1 NA
#> 6 2021 5 female Victoria VIC lc 1 NA
#> 7 2021 6 female Victoria VIC lc 1 NA
#> 8 2021 7 female Victoria VIC lc 1 NA
#> 9 2021 8 female Victoria VIC lc 1 NA
#> 10 2021 9 female Victoria VIC lc 1 NA
#> # ℹ 1,808 more rows