1
$\begingroup$

How can I plot Impulse Responses Functions and confidence bands in R as shown in the image below:

I enter image description here

$\endgroup$
3
  • $\begingroup$ See the vars package. $\endgroup$ – Christoph Hanck Sep 11 '15 at 14:56
  • $\begingroup$ Thanks @Christoph, but I want to have some sort of shading between the confidence bands as in this image. $\endgroup$ – mr.rox Sep 11 '15 at 14:59
  • $\begingroup$ If you retrieve the upper and lower values of the bands, you can do that with the general purpose polygon command. $\endgroup$ – Christoph Hanck Sep 11 '15 at 15:01
2
$\begingroup$

Here is an answer using the polygon function in R

#Generate some psuedo data
x = seq(0,10,.01)
IRF = sin(pi*x/5)+.8*cos(4*pi*x/5)  #This is the IRF values
lower = IRF - 1                     #Lower 95% limit
upper = IRF + 1                     #Upper 95% limit

plot(x,IRF,type="n",ylim=c(-3,3))
polygon(c(x,rev(x)),c(lower,rev(upper)),col="lightgrey",border=NA)  #This function creates the CI bands
lines(x,IRF,col="darkblue")
box()

This code generates the following image:

enter image description here

$\endgroup$
1
  • $\begingroup$ My code makes the assumptions that you can calculate or have the values for IRF and the upper and lower limits of the confidence interval. $\endgroup$ – user30490 Sep 11 '15 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.