Compute Generalized or Orthogonalized Impulse Response Functions (IRFs) from
mvgam
models with Vector Autoregressive dynamics
Usage
irf(object, ...)
# S3 method for mvgam
irf(object, h = 10, cumulative = FALSE, orthogonal = FALSE, ...)
Arguments
- object
list
object of classmvgam
resulting from a call tomvgam()
that used a Vector Autoregressive latent process model (either asVAR(cor = FALSE)
orVAR(cor = TRUE)
)- ...
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
Value
An object of class mvgam_irf
containing the posterior IRFs. This
object can be used with the supplied S3 functions plot
Details
Generalized or Orthogonalized Impulse Response Functions can be computed
using the posterior estimates of Vector Autoregressive parameters. This function
generates a positive "shock" for a target process at time t = 0
and then
calculates how each of the remaining processes in the latent VAR are expected
to respond over the forecast horizon h
. The function computes IRFs for all
processes in the object and returns them in an array that can be plotted using
the S3 plot
function. To inspect community-level metrics of stability using latent
VAR processes, you can use the related stability
function.
References
PH Pesaran & Shin Yongcheol (1998). Generalized impulse response analysis in linear multivariate models. Economics Letters 58: 17–29.
Examples
# \donttest{
# 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(y ~ -1,
trend_formula = ~1,
trend_model = VAR(cor = TRUE),
family = gaussian(),
data = simdat$data_train,
chains = 2,
silent = 2
)
# 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)
# Calculate posterior median, upper and lower 90th quantiles
# of the impulse responses
summary(irfs)
#> # A tibble: 192 × 5
#> shock horizon irf_median irf_Qlower irf_Qupper
#> <chr> <int> <dbl> <dbl> <dbl>
#> 1 Process1 -> Process1 1 0.582 0.312 0.807
#> 2 Process1 -> Process1 2 -0.0180 -0.302 0.288
#> 3 Process1 -> Process1 3 -0.365 -0.606 -0.117
#> 4 Process1 -> Process1 4 -0.0628 -0.301 0.196
#> 5 Process1 -> Process1 5 0.248 0.0819 0.442
#> 6 Process1 -> Process1 6 0.117 -0.0561 0.291
#> 7 Process1 -> Process1 7 -0.113 -0.323 0.0267
#> 8 Process1 -> Process1 8 -0.0908 -0.278 0.0668
#> 9 Process1 -> Process1 9 0.0689 -0.0819 0.231
#> 10 Process1 -> Process1 10 0.0829 -0.0243 0.254
#> # ℹ 182 more rows
# }