BolzanoW
BolzanoW

Reputation: 675

Plot side-by-side Impulse Response in R package "vars"

library(vars)
data(Canada)
var_fit <- VAR(Canada, p = 1)
var_irf <- irf(var_fit, impulse = c("U", "rw"), response = "prod")

How do I plot the two Impulse Responses in a figure side-by-side

Normally, I'd use par(mfrow = c(1,2)), but it doesn't work as expected. Any help?

Upvotes: 3

Views: 1692

Answers (1)

H&#233;ctor Garrido
H&#233;ctor Garrido

Reputation: 185

I found the same problem. I solved "manually", here a example for a model VAR(1) with two variables.

    impulse<-irf(model)
    irf1<-data.frame(impulse$irf$y1[,1],impulse$Lower$y1[,1],
                     impulse$Upper$y1[,1])
    irf2<-data.frame(impulse$irf$y1[,2],impulse$Lower$y1[,2],
                     impulse$Upper$y1[,2])
    par(mfrow=c(1,2), bg="azure2")
    matplot(irf1, type="l", lwd=2, col="blue2", 
            ylab=expression(y[1]), lty=c(1,2,2))
    matplot(irf2, type="l", lwd=2, col="red2", 
            ylab=expression(y[1]), lty=c(1,2,2))

Upvotes: 1

Related Questions