[R] Help with graphing impulse response functions

David Winsemius dwinsemius at comcast.net
Sat Aug 14 19:37:35 CEST 2010


On Aug 14, 2010, at 11:43 AM, Musky Dee wrote:

> Dear colleagues/contributors,
>
> I'd be pleased if someone could provide insights on how to plot  
> impulse response functions in a format that can easily be copied in  
> a word document just as plotting time-series of variables.
>
> I had followed the outline suggested by Benhard Pfaff [see http://127.0.0.1:17693/library/vars/html/irf.html 
> ] but I am unable to get the impulse response functions in a single  
> graphical format. I then tried this command, where each variable  
> response to an impulse was plotted:
>
> opar <-par(mfrow = c(3,2), mar=c(4.2,4.2,1,1), oma=c(0,0,0,0))
> plot(svec.irfT1,main="T->G", ylab="", xlab="")
> plot(svec.irfT2, main="T->i",ylab="")
> plot(svec.irfT3,main="T->Y",ylab="")
> plot(svec.irfT4,main="T->T",ylab="")
> plot(svec.irfT5,main="T->P",ylab="")
> plot(svec.irfT,ylab="")
> par(opar)
>
> However the graphs still fail to appear in a three row, two column  
> format that could be easily copied to word or pdf. Kind assistance  
> will be welcome.

That's not too surprising. Look at the function that does the plotting :

 > class(irf1)
[1] "varirf"
 > getAnywhere(plot.varirf)
A single object matching ‘plot.varirf’ was found
It was found in the following places
   registered S3 method for plot from namespace vars
   namespace:vars
with value

function (x, plot.type = c("multiple", "single"), names = NULL,
     main = NULL, sub = NULL, lty = NULL, lwd = NULL, col = NULL,
     ylim = NULL, ylab = NULL, xlab = NULL, nc, mar.multi = c(0,
         4, 0, 4), oma.multi = c(6, 4, 6, 4), adj.mtext = NA,
     padj.mtext = NA, col.mtext = NA, ...)
{
     op <- par(no.readonly = TRUE)
     on.exit(par(op))
.
.
.... remainder of function deleted

plot.varirf does its own layout, after setting asside you par  
specifications and reloading them on exit, but if you look at the  
argument list, I think it is clear that there was provision made for  
adjustments to mar and oma arguments. I think you need to read the  
docemantion (and maybe the code as well)  more closely to see how the  
authors expected that function to be used.

-- 
David.


>
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list