fevd.mvgam: Calculate latent VAR forecast error variance decompositions

View source: R/fevd.mvgam.R

fevd.mvgamR Documentation

Calculate latent VAR forecast error variance decompositions

Description

Compute forecast error variance decompositions from mvgam models with Vector Autoregressive dynamics

Usage

fevd(object, ...)

## S3 method for class 'mvgam'
fevd(object, h = 10, ...)

Arguments

object

list object of class mvgam resulting from a call to mvgam() that used a Vector Autoregressive latent process model (either as VAR(cor = FALSE) or VAR(cor = TRUE); see VAR() for details)

...

ignored

h

Positive integer specifying the forecast horizon over which to calculate the IRF

Value

See mvgam_fevd-class for a full description of the quantities that are computed and returned by this function, along with key references.

Author(s)

Nicholas J Clark

See Also

VAR(), irf(), stability(), mvgam_fevd-class

Examples


# Simulate some time series that follow a latent VAR(1) process
simdat <- sim_mvgam(
  family = gaussian(),
  n_series = 4,
  trend_model = VAR(cor = TRUE),
  prop_trend = 1
)
plot_mvgam_series(data = simdat$data_train, series = "all")

# Fit a model that uses a latent VAR(1)
mod <- mvgam(
  formula = y ~ -1,
  trend_formula = ~ 1,
  trend_model = VAR(cor = TRUE),
  family = gaussian(),
  data = simdat$data_train,
  chains = 2,
  silent = 2
)

# Plot the autoregressive coefficient distributions;
# use 'dir = "v"' to arrange the order of facets
# correctly
mcmc_plot(
  mod,
  variable = 'A',
  regex = TRUE,
  type = 'hist',
  facet_args = list(dir = 'v')
)

# Calulate forecast error variance decompositions for each series
fevds <- fevd(mod, h = 12)

# Plot median contributions to forecast error variance
plot(fevds)

# View a summary of the error variance decompositions
summary(fevds)


nicholasjclark/mvgam documentation built on April 17, 2025, 9:39 p.m.