### extend basic example in "vars" ###
library(vars)
data(Canada)
names_k = c("e", "U", "rw") # names of endogenous variables
names_l = c("prod") # names of exogenous variables
names_s = NULL # optional shock names
x = Canada[ , names_l, drop=FALSE]
y = Canada[ , names_k, drop=FALSE]
# colnames of the restriction matrices are passed as shock names #
SR = matrix(NA, nrow=4, ncol=4, dimnames=list(NULL, names_s))
SR[4, 2] = 0
LR = matrix(NA, nrow=4, ncol=4, dimnames=list(NULL, names_s))
LR[1, 2:4] = 0
LR[2:4, 4] = 0
# estimate, identify, and plot the IRF #
R.vecm = VECM(y=y, dim_p=3, x=x, dim_q=3, dim_r=1, type="Case4")
R.grt = id.grt(R.vecm, LR=LR, SR=SR)
R.irf = irf(R.grt, n.ahead=50)
plot(R.irf)
Run the code above in your browser using DataLab