data("PCAP")
names_k = c("g", "k", "l", "y") # variable names
names_i = levels(PCAP$id_i) # country names
L.data = sapply(names_i, FUN=function(i)
ts(PCAP[PCAP$id_i==i, names_k], start=1960, end=2019, frequency=1),
simplify=FALSE)
# estimate and identify panel SVAR #
L.vars = lapply(L.data, FUN=function(x) vars::VAR(x, p=2, type="both"))
R.pid = pid.chol(L.vars, order_k=names_k)
# calculate and plot MG-IRF #
library("ggplot2")
R.irf = irf(R.pid, n.ahead=60)
F.irf = plot(R.irf, selection=list(2:4, 1:2))
as.pplot(F.irf=F.irf, color_g="black", n.rows=3)$F.plot + guides(color="none")
Run the code above in your browser using DataLab