Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

irf

Impulse Response Function


Description

This function calculates three alternative ways of dynamic responses, namely generalized impulse response functions (GIRFs) as in Pesaran and Shin (1998), orthogonalized impulse response functions using a Cholesky decomposition and finally impulse response functions given a set of user-specified sign restrictions.

Usage

irf(x, n.ahead=24, ident="chol", shockinfo=NULL, quantiles=NULL, 
    expert=NULL, verbose=TRUE)

Arguments

x

Object of class bgvar.

n.ahead

Forecasting horizon.

ident

Character defining type of identification scheme. Default chol refers to zero restrictions via the Cholesky decomposition while sign refers to sign-restrictions and girf to generalized impulse responses. Details of preferred shock are given via shockinfo.

shockinfo

Dataframe with additional information about the nature of shocks. Depending on the ident argument, the dataframe has to be specified differently. In order to get a dummy version for each identification scheme use get_shockinfo.

quantiles

Numeric vector with posterior quantiles. Default is set to compute median along with 68%/80%/90% confidence intervals.

expert

Expert settings, must be provided as list. Default is set to NULL.

  • MaxTries Numeric specifying maximal number of tries for finding a rotation matrix with sign-restrictions. Attention: setting this number very large may results in very long computational times.

  • save.store If set to TRUE the full posterior of both, impulses responses and rotation matrices, are returned. Default is set to FALSE in order to save storage.

  • use_R Boolean whether IRF computation should fall back on R version, otherwise Rcpp version is used.

  • applyfun In case use_R=TRUE, this allows for user-specific apply function, which has to have the same interface than lapply. If cores=NULL then lapply is used, if set to a numeric either parallel::parLapply() is used on Windows platforms and parallel::mclapply() on non-Windows platforms.

  • cores Numeric specifying the number of cores which should be used, also all and half is possible. By default only one core is used.

verbose

If set to FALSE it suppresses printing messages to the console.

Value

Returns a list of class bgvar.irf with the following elements:

  • posterior Four-dimensional array (K times n.ahead times number of shocks times Q) that contains Q quantiles of the posterior distribution of the impulse response functions.

  • ident Character showing the chosen identification scheme.

  • shockinfo Dataframe with details on identification specification.

  • rot.nr In case identification is based on sign restrictions (i.e., ident="sign"), this provides the number of rotation matrices found for the number of posterior draws (save*save_thin).

  • struc.obj List object that contains posterior quantitites needed when calculating historical decomposition and structural errors via hd.decomp.

    • A Median posterior of global coefficient matrix.

    • Ginv Median posterior of matrix Ginv, which describes contemporaneous relationships between countries.

    • S Posterior median of matrix with country variance-covariance matrices on the main diagonal.

    • Rmed Posterior rotation matrix if ident="sign".

  • model.obj List object that contains model-specific information, in particular

    • xglobal Data of the model.

    • plag Lag specification of the model.

  • IRF_store Four-dimensional array (K times n.ahead times number of shock times draws) which stores the whole posterior distribution. Exists only if save.store=TRUE.

  • R_store Three-dimensional array (K times K times draws) which stores all rotation matrices. Exists only if save.store=TRUE.

Author(s)

Maximilian Boeck, Martin Feldkircher, Florian Huber

References

Arias, J.E., Rubio-Ramirez, J.F, and D.F. Waggoner (2018) Inference Based on SVARs Identified with Sign and Zero Restrictions: Theory and Applications. Econometrica Vol. 86(2), pp. 685-720.

D'Amico, S. and T. B. King (2017) What Does Anticipated Monetary Policy Do? Federal Reserve Bank of Chicago Working paper series, Nr. 2015-10.

Pesaran, H.M. and Y. Shin (1998) Generalized impulse response analysis in linear multivariate models. Economics Letters, Volume 58, Issue 1, p. 17-29.

See Also

Examples

oldpar <- par(no.readonly = TRUE)
# First example, a US monetary policy shock, quarterly data
library(BGVAR)
data(eerDatasmall)
# US monetary policy shock
model.eer<-bgvar(Data=eerDatasmall, W=W.trade0012.small, draws=100, burnin=100, 
                 plag=1, prior="SSVS", eigen=TRUE)

# define shock
shockinfo <- get_shockinfo("chol")
shockinfo$shock <- "US.stir"; shockinfo$scale <- -100

# generalized impulse responses
irf.girf.us.mp<-irf(model.eer, n.ahead=24, ident="girf", shockinfo=shockinfo)

# cholesky identification
irf.chol.us.mp<-irf(model.eer, n.ahead=24, ident="chol", shockinfo=shockinfo)

# sign restrictions
shockinfo <- get_shockinfo("sign")
shockinfo <- add_shockinfo(shockinfo, shock="US.stir", restriction=c("US.y","US.Dp"), 
sign=c("<","<"), horizon=c(1,1), scale=1, prob=1)
irf.sign.us.mp<-irf(model.eer, n.ahead=24, ident="sign", shockinfo=shockinfo)

# sign restrictions with relaxed cross-country restrictions
shockinfo <- get_shockinfo("sign")
# restriction for other countries holds to 75\%
shockinfo <- add_shockinfo(shockinfo, shock="US.stir", restriction=c("US.y","EA.y","UK.y"), 
                           sign=c("<","<","<"), horizon=1, scale=1, prob=c(1,0.75,0.75))
shockinfo <- add_shockinfo(shockinfo, shock="US.stir", restriction=c("US.Dp","EA.Dp","UK.Dp"),
                           sign=c("<","<","<"), horizon=1, scale=1, prob=c(1,0.75,0.75))
irf.sign.us.mp<-irf(model.eer, n.ahead=24, ident="sign", shockinfo=shockinfo)

# Example with zero restriction (Arias et al., 2018) and 
# rationality conditions (D'Amico and King, 2017).
data("eerDataspf")
model.eer<-bgvar(Data=eerDataspf, W=W.trade0012.spf, draws=300, burnin=300,
                 plag=1, prior="SSVS", eigen=TRUE)
shockinfo <- get_shockinfo("sign")
shockinfo <- add_shockinfo(shockinfo, shock="US.stir_t+4", 
                           restriction=c("US.Dp_t+4","US.stir","US.y_t+4"),
                           sign=c("<","0","<"), horizon=1, prob=1, scale=1)
# rationality condition: US.stir_t+4 on impact is equal to average of 
# IRF of US.stir between horizon 1 to 4
shockinfo <- add_shockinfo(shockinfo, shock="US.stir_t+4", restriction="US.stir_t+4",
                           sign="ratio.avg", horizon=5, prob=1, scale=1)
# rationality condition: US.Dp_t+4 on impact is equal to IRF of US.Dp at horizon 4
shockinfo <- add_shockinfo(shockinfo, shock="US.stir_t+4", restriction="US.Dp_t+4",
                           sign="ratio.H", horizon=5, prob=1, scale=1)
# rationality condition: US.y_t+4 on impact is equal to IRF of US.y at horizon 4
shockinfo <- add_shockinfo(shockinfo, shock="US.stir_t+4", restriction="US.y_t+4",
                           sign="ratio.H", horizon=5, prob=1, scale=1)
# regulate maximum number of tries with expert settings
irf.ratio <- irf(model.eer, n.ahead=20, ident="sign", shockinfo=shockinfo,
                 expert=list(MaxTries=10))

BGVAR

Bayesian Global Vector Autoregressions

v2.2.0
GPL-3
Authors
Maximilian Boeck [aut, cre] (<https://orcid.org/0000-0001-6024-8305>), Martin Feldkircher [aut] (<https://orcid.org/0000-0002-5511-9215>), Florian Huber [aut] (<https://orcid.org/0000-0002-2896-7921>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.