Skip to contents

Compute forecast error variance decompositions from mvgam models with Vector Autoregressive dynamics. A decomposition gives the share of each series' forecast uncertainty at horizons up to h that comes from the innovations of each series.

Usage

fevd(object, ...)

# S3 method for class 'mvgam'
fevd(
  object,
  h = 10,
  ndraws = NULL,
  draw_ids = NULL,
  summary = TRUE,
  probs = c(0.025, 0.975),
  future = FALSE,
  ...
)

Arguments

object

An object of class mvgam fitted with a VAR() latent process model

...

Unused. Anything passed here is refused.

h

Positive integer. The number of forecast horizons to decompose.

ndraws

Positive integer specifying number of posterior draws to use. NULL (default) uses all available draws.

draw_ids

Optional integer vector selecting a subset of posterior draw indices to use. NULL (default) uses all draws (subject to ndraws).

summary

Logical; return the posterior median and interval of each decomposition (the default), or the per-draw decompositions themselves.

probs

The lower and upper percentiles of the interval reported with the median when summary = TRUE.

future

Logical. When TRUE, the per-draw computation runs under the future::plan() the caller has set. The default sequential plan runs as base lapply() does. plan(multisession, workers = N) splits the draws across N R processes. Without the future package the draws run in turn, with a message.

Value

An object of mvgam_fevd-class, which describes the quantities computed, with references.

References

Lutkepohl H (2005). New Introduction to Multiple Time Series Analysis. Springer, Berlin. doi:10.1007/978-3-540-27752-1

See also

irf() and stability() summarise the same VAR dynamics. forecast_uncertainty() splits a forecast of any model by source. The VAR article runs fevd() on a plankton community.

Other latent dynamics: active_factors(), compare_loadings(), irf.mvgam(), ordinate(), posterior_transition_matrix(), residual_cor(), shared_variation(), stability.mvgam()

Author

Nicholas J Clark

Examples

# \dontrun{
# Ten years of monthly counts of a prey species and its predator.
# Predators suppress the prey a month later. Prey raise the
# predators a month later.
set.seed(2025)
n_months <- 120
A <- rbind(prey     = c(0.6, -0.5),
           predator = c(0.4,  0.5))
z <- matrix(0, n_months, 2)
for (t in 2:n_months) {
  z[t, ] <- A %*% z[t - 1, ] + rnorm(2, sd = 0.35)
}
predator_prey <- data.frame(
  time = rep(seq_len(n_months), 2),
  series = factor(rep(c("prey", "predator"), each = n_months),
                  levels = c("prey", "predator")),
  y = rpois(2 * n_months, exp(c(2.5 + z[, 1], 1.5 + z[, 2])))
)
var_mod <- mvgam(y ~ series, trend_formula = ~ VAR(),
                 data = predator_prey, family = poisson(),
                 chains = 2, silent = 2)
# }
# \dontrun{
# The share of each series' forecast-error variance due to each
# shock, over an eight-step horizon
fevd_obj <- fevd(var_mod, h = 8L)
plot(fevd_obj)


# Next: irf() traces each shock through the system over time
# }