Produces forecasts from a trained model.

# S3 method for class 'VAR'
forecast(
  object,
  new_data = NULL,
  specials = NULL,
  bootstrap = FALSE,
  times = 5000,
  ...
)

Arguments

object

A model for which forecasts are required.

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.

times

The number of sample paths to use in estimating the forecast distribution when bootstrap = TRUE.

...

Other arguments passed to methods

Value

A list of forecasts.

Examples

lung_deaths <- cbind(mdeaths, fdeaths) %>%
  as_tsibble(pivot_longer = FALSE)

lung_deaths %>%
  model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) %>%
  forecast()
#> # A fable: 24 x 4 [1M]
#> # Key:     .model [1]
#>    .model                                 index .distribution .mean[,"mdeaths"]
#>    <chr>                                  <mth>        <dist>             <dbl>
#>  1 VAR(vars(mdeaths, fdeaths) ~ AR(3)) 1980 Jan        MVN[2]             1486.
#>  2 VAR(vars(mdeaths, fdeaths) ~ AR(3)) 1980 Feb        MVN[2]             1445.
#>  3 VAR(vars(mdeaths, fdeaths) ~ AR(3)) 1980 Mar        MVN[2]             1369.
#>  4 VAR(vars(mdeaths, fdeaths) ~ AR(3)) 1980 Apr        MVN[2]             1340.
#>  5 VAR(vars(mdeaths, fdeaths) ~ AR(3)) 1980 May        MVN[2]             1327.
#>  6 VAR(vars(mdeaths, fdeaths) ~ AR(3)) 1980 Jun        MVN[2]             1349.
#>  7 VAR(vars(mdeaths, fdeaths) ~ AR(3)) 1980 Jul        MVN[2]             1395.
#>  8 VAR(vars(mdeaths, fdeaths) ~ AR(3)) 1980 Aug        MVN[2]             1442.
#>  9 VAR(vars(mdeaths, fdeaths) ~ AR(3)) 1980 Sep        MVN[2]             1477.
#> 10 VAR(vars(mdeaths, fdeaths) ~ AR(3)) 1980 Oct        MVN[2]             1495.
#> # ℹ 14 more rows
#> # ℹ 1 more variable: .mean[2] <dbl>