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 = 1, 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,
silent = 2)
<<<<<<< HEAD
#> In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
#> from stan/lib/stan_math/stan/math/prim/prob/von_mises_ccdf_log.hpp:4,
#> from stan/lib/stan_math/stan/math/prim/prob.hpp:359,
#> from stan/lib/stan_math/stan/math/prim.hpp:16,
#> from stan/lib/stan_math/stan/math/rev.hpp:16,
#> from stan/lib/stan_math/stan/math.hpp:19,
#> from stan/src/stan/model/model_header.hpp:4,
#> from C:/Users/uqnclar2/AppData/Local/Temp/Rtmp2bnpq5/model-3cd02a896e3e.hpp:2:
#> stan/lib/stan_math/stan/math/prim/prob/von_mises_cdf.hpp: In function 'stan::return_type_t<T_x, T_sigma, T_l> stan::math::von_mises_cdf(const T_x&, const T_mu&, const T_k&)':
#> stan/lib/stan_math/stan/math/prim/prob/von_mises_cdf.hpp:194: note: '-Wmisleading-indentation' is disabled from this point onwards, since column-tracking was disabled due to the size of the code/headers
#> 194 | if (cdf_n < 0.0)
#> |
#> stan/lib/stan_math/stan/math/prim/prob/von_mises_cdf.hpp:194: note: adding '-flarge-source-files' will allow for more column-tracking support, at the expense of compilation time and memory
=======
>>>>>>> 79e31b766e09ac39e22b93cb199f3eb4fda5e08f
# 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)
# }