IRF {BGVAR} | R Documentation |
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.
IRF(gvar.obj, shockc = NULL, nhor = 24, sign.constr = NA,rotSpec=NULL,cpu=1,full.post=FALSE)
gvar.obj |
An objected fitted by function |
shockc |
This is a list object. It should contain an entry labelled |
nhor |
Forecasting horizon. |
sign.constr |
The user should submit a list containing the following entries:
|
rotSpec |
Only needed for sign restrictions. Is a list with two entries, |
cpu |
Number of cpu cores for use of parallel computing using the |
full.post |
If |
posterior
is a four-dimensional array (K times nhor times nr. of shokcs times 7) that contains 7 quantiles of the posterior distribution of the impulse response functions: the 50% ("low25" and "high75"), the 68% ("low16" and "high84") and the 90% ("low05" and "high95") credible sets along with the posterio meidan ("median")
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).
sign.constr
in case identification is based on sign restrictions (i.e., ident="sign"
), this gives back the set of sign restrictions specified by the user.
xglobal
is a matrix object that contains the original time series, which is of dimension T times N (T # of observations, K # of variables in the system).
struc.obj
is a list object that contains posterior quantitites needed when calculating historical decompositions and structural erros via hd.decomp
.
Sigma_u
is a two-dimensional array (K times K) of the (block-diagonal) posterior median of the variance covariance matrix.
xglobal
is a matrix object that contains the original time series, which is of dimension K times T.
plag
is the number of lags used when estimating the model with bgvar
.
ALPHA
is a two-dimensional array (K times K+1 ) of the posterior median for the K coefficients plus a global constant.
Rmed
x
is a matrix object that contains the original time series, which is of dimension K times (T-plag).
log.txt
is an automatically generated text file if cpu
is set greater than one. It contains information about the amount of
successfully sampled rotation matrices and is located in the current working directory. See also rot.eval
to further process information about the state of rotation matrix sampling.
Martin Feldkircher and Florian Huber
Pesaran, H.M. and Y. Shin (1998) Generalized impulse response analysis in linear multivariate models. In: Economics Letters, Volume 58, Issue 1.
See also eerData
for an example with sign restrictions.
# First example, a US monetary policy shock, quarterly data library(BGVAR) data(eerData) model.ssvs.eer<-bgvar(Data=eer.data,W=W.trade0012,saves=100,burns=100,plag=1,Cpu=1,prior="SSVS",save_thin=1,eigen=TRUE, trim=1.05) # US monetary policy shock shocks<-list();shocks$shock="stir";shocks$ccode<-"US";shocks$ident="chol";shocks$scal=-100 irf.chol.us.mp<-IRF(gvar.obj=model.ssvs.eer,shockc=shocks,nhor=48) # plots an impulse response function irf.plot(irf.chol.us.mp,resp="US.y") # calculates generalized impulse response functions for the same shock as above shocks$ident="GIRF" irf.girf.ssvs<-IRF(gvar.obj=model.ssvs.eer,shockc=shocks,nhor=48) irf.plot(irf.girf.ssvs,resp="US.y") # Shock to first ordered variable yields same responses of cholesky and GIRF shocks<-list();shocks$shock="y";shocks$ccode<-"US";shocks$ident="chol";shocks$scal=+1 irf.chol<-IRF(model.ssvs.eer,shockc=shocks,nhor=48) shocks$ident<-"GIRF" irf.girf<-IRF(model.ssvs.eer,shockc=shocks,nhor=48) matplot(cbind(irf.chol$posterior["US.y",,1,"median"],irf.girf$posterior["US.y",,1,"median"]),type="l",ylab="") matplot(cbind(irf.chol$posterior["US.Dp",,1,"median"],irf.girf$posterior["US.Dp",,1,"median"]),type="l",ylab="") matplot(cbind(irf.chol$posterior["EA.y",,1,"median"],irf.girf$posterior["EA.y",,1,"median"]),type="l",ylab="") # second example, cross-country restrictions, multiple shocks and ECB country model library(BGVAR) data(monthlyData2);new.data2$OC<-NULL # estimates the model model.ssvs<-bgvar(Data=new.data2,W=W,saves=100,burns=100,plag=1,Cpu=1,prior="SSVS",save_thin=1,eigen=TRUE,trim=1.05,ea.weights=EA.weights) EA_countries <- c("AT", "BE", "DE","ES", "FI","FR", "IE", "IT", "NL", "PT","GR","SK") #,"MT","CY","EE","LT","LV") # A simultaneous cholesky shock to long-term interest rates in the euro area countries, scaled to amount to -100 basis points (on average over the EA countries). # Note that the ordering of the variables influences the response, the ordering is exactly as in the country models, to use a different order you have re-estimate # the model (by bgvar) shocks<-list();shocks$shock="ltir";shocks$ccode<-EA_countries;shocks$ident="chol";shocks$scal=-100 irf.chol.ssvs<-IRF(gvar.obj=model.ssvs,shockc=shocks,nhor=48) # imposes sign restrictions on the cross-section and for a global shock (long-term interest rates) sign.constr<-list() sign.constr$shock1$shock<-c(paste0(EA_countries[-c(3,12)],".ltir")) # the variable to shock, can be imposed for more than one country #but should be the same variable for all of them sign.constr$shock1$restrictions$res1<-paste0(EA_countries,".y") # restrictions (industrial production should decrease for selected countries) sign.constr$shock1$restrictions$res2<-paste0(EA_countries,".p") # another set of restrictions (inflation should decrease for selected countries) sign.constr$shock1$sign<-c(">","<","<") # first entry is for the shock, following entries for the restrictions (ltir should go up, y and p go down) sign.constr$shock1$rest.horz<-c(1,1,1) # nr. of time periods restrictions are imposed, first entry is for the shock, following entries for the restrictions sign.constr$shock1$constr<-c(1,0.5,0.5) # are constraints binding for all (1) countries specified or for at least 50% of the countries (0.5), or 75% (0.75) sign.constr$shock1$scal=-100 # a minus 100 bp shock to long-term interest rates (on average) rotSpec<-list();rotSpec$MaxTries<-200;rotSpec$Srots<-1 irf.sign.ssvs<-IRF(gvar.obj=model.ssvs,shockc=NULL,nhor=48,rotSpec=rotSpec,sign.constr=sign.constr) # Same example but using a local (German) shock and cross-country restrictions. # Note that the ordering of the variables influences the response, the ordering is exactly as in the country models, to use a different order you have re-estimate # the model (by bgvar) shocks<-list();shocks$shock="ltir";shocks$ccode<-EA_countries;shocks$ident="chol";shocks$scal=-100 irf.chol.ssvs<-IRF(gvar.obj=model.ssvs,shockc=shocks,nhor=48) # imposes sign restrictions on the cross-section and for a global shock (long-term interest rates) sign.constr<-list() sign.constr$shock1$shock<-c("DE.ltir") # the variable to shock, can be imposed for more than one country #but should be the same variable for all of them sign.constr$shock1$restrictions$res1<-paste0(EA_countries,".y") # restrictions (industrial production should decrease for selected countries) sign.constr$shock1$restrictions$res2<-paste0(EA_countries,".p") # another set of restrictions (inflation should decrease for selected countries) sign.constr$shock1$sign<-c(">","<","<") # first entry is for the shock, following entries for the restrictions (ltir should go up, y and p go down) sign.constr$shock1$rest.horz<-c(2,2,1) # nr. of time periods restrictions are imposed, first entry is for the shock, following entries for the restrictions sign.constr$shock1$constr<-c(1,0.5,0.5) # are constraints binding for all (1) countries specified or for at least 50% of the countries (0.5), or 75% (0.75) sign.constr$shock1$scal=-100 # a minus 100 bp shock to long-term interest rates (on average) rotSpec<-list();rotSpec$MaxTries<-200;rotSpec$Srots<-1 irf.sign.ssvs<-IRF(gvar.obj=model.ssvs,shockc=NULL,nhor=48,rotSpec=rotSpec,sign.constr=sign.constr)