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_datafor 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
norway_mortality |>
model(lc = LC(log(Mortality))) |>
generate(times = 3, bootstrap = TRUE)
#> # A vital: 1,998 x 6 [1Y]
#> # Key: Age x (Sex, .model, .rep) [111 x 9]
#> Year Age Sex .model .rep .sim
#> <int> <int> <chr> <chr> <chr> <dbl>
#> 1 2024 0 Female lc 1 0.00126
#> 2 2024 1 Female lc 1 0.0000721
#> 3 2024 2 Female lc 1 0.0000485
#> 4 2024 3 Female lc 1 0.0000393
#> 5 2024 4 Female lc 1 0.0000412
#> 6 2024 5 Female lc 1 0.0000335
#> 7 2024 6 Female lc 1 0.0000314
#> 8 2024 7 Female lc 1 0.0000303
#> 9 2024 8 Female lc 1 0.0000345
#> 10 2024 9 Female lc 1 0.0000296
#> # ℹ 1,988 more rows