Produces forecasts from a trained model.
# S3 method for class 'TSLM'
forecast(
object,
new_data,
specials = NULL,
bootstrap = FALSE,
approx_normal = TRUE,
times = 5000,
...
)
A model for which forecasts are required.
A tsibble containing the time points and exogenous regressors to produce forecasts for.
(passed by fabletools::forecast.mdl_df()
).
If TRUE
, then forecast distributions are computed using simulation with resampled errors.
Should the resulting forecast distributions be approximated as a Normal distribution instead of a Student's T distribution. Returning Normal distributions (the default) is a useful approximation to make it easier for using TSLM models in model combinations or reconciliation processes.
The number of sample paths to use in estimating the forecast distribution when bootstrap = TRUE
.
Other arguments passed to methods
A list of forecasts.
as_tsibble(USAccDeaths) %>%
model(lm = TSLM(log(value) ~ trend() + season())) %>%
forecast()
#> # A fable: 24 x 4 [1M]
#> # Key: .model [1]
#> .model index value .mean
#> <chr> <mth> <dist> <dbl>
#> 1 lm 1979 Jan t(N(8.9, 0.003)) 7620.
#> 2 lm 1979 Feb t(N(8.8, 0.003)) 6899.
#> 3 lm 1979 Mar t(N(8.9, 0.003)) 7639.
#> 4 lm 1979 Apr t(N(9, 0.003)) 7841.
#> 5 lm 1979 May t(N(9.1, 0.003)) 8645.
#> 6 lm 1979 Jun t(N(9.1, 0.003)) 9087.
#> 7 lm 1979 Jul t(N(9.2, 0.003)) 9908.
#> 8 lm 1979 Aug t(N(9.1, 0.003)) 9237.
#> 9 lm 1979 Sep t(N(9, 0.003)) 8237.
#> 10 lm 1979 Oct t(N(9, 0.003)) 8516.
#> # ℹ 14 more rows