irf.mvgam: Calculate latent VAR impulse response functions

View source: R/irf.mvgam.R

irf.mvgamR Documentation

Calculate latent VAR impulse response functions

Description

Compute Generalized or Orthogonalized Impulse Response Functions (IRFs) from mvgam models with Vector Autoregressive dynamics

Usage

irf(object, ...)

## S3 method for class 'mvgam'
irf(object, h = 10, cumulative = FALSE, orthogonal = FALSE, ...)

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

cumulative

Logical flag indicating whether the IRF should be cumulative

orthogonal

Logical flag indicating whether orthogonalized IRFs should be calculated. Note that the order of the variables matters when calculating these

Details

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

Value

An object of mvgam_irf-class containing the posterior IRFs. This object can be used with the supplied S3 functions plot.mvgam_irf() and summary.mvgam_irf()

Author(s)

Nicholas J Clark

See Also

mvgam_irf-class, VAR(), plot.mvgam_irf(), stability(), fevd()

Examples


# Fit a model to the portal time series that uses a latent VAR(1)
mod <- mvgam(
  formula = captures ~ -1,
  trend_formula = ~ trend,
  trend_model = VAR(cor = TRUE),
  family = poisson(),
  data = portal_data,
  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 Generalized IRFs for each series
irfs <- irf(
  mod,
  h = 12,
  cumulative = FALSE
)

# Plot them
plot(irfs, series = 1)
plot(irfs, series = 2)
plot(irfs, series = 3)
plot(irfs, series = 4)

# Calculate posterior median, upper and lower 95th quantiles
# of the impulse responses
summary(irfs)


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