mboeck11 / BGVAR

Toolbox for the estimation of Bayesian Global Vector Autoregressions in R.
27 stars 20 forks source link

Cumulative plot is not working #6

Closed bttomio closed 3 years ago

bttomio commented 3 years ago

Hello,

When trying to plot with cumulative = TRUE, I'm getting the following error message: Error in apply(y, 2, cumsum) : object 'y' not found

This is the code used:

library(BGVAR)

cN<-c("EA","US","RU")
eerData<-eerData[cN]
W.trade0012<-W.trade0012[cN,cN]
W.trade0012<-apply(W.trade0012,2,function(x)x/rowSums(W.trade0012))
W.list<-lapply(W.list,function(l){l<-apply(l[cN,cN],2,function(x)x/rowSums(l[cN,cN]))})

model.ssvs.1<-bgvar(Data=eerData,
                    W=W.trade0012,
                    draws=100,
                    burnin=100,
                    plag=1,
                    prior="SSVS",
                    hyperpara=NULL, 
                    SV=TRUE,
                    thin=1,
                    trend=TRUE,
                    h=0,
                    eigen=1,
                    expert=list(save.shrink.store = TRUE)
)

model.ssvs.1$cc.results$PIP$PIP.cc$EA
model.ssvs.1$cc.results$PIP$PIP.avg

shockinfo_girf<-get_shockinfo(ident = "girf")
shockinfo_girf$shock<-"US.stir"
shockinfo_girf$scale<--100
irf.chol.us.mp<-irf(
  model.ssvs.1, 
  n.ahead=24, 
  shockinfo=shockinfo_girf, 
  expert=list(save.store=TRUE))
plot(irf.chol.us.mp, resp="US", shock="US.stir", cumulative = TRUE)

I've seen that the plot.R has changed significantly recently. Could you please check what is going on with the error message? Please let me know if there is anything I can do to help.

Thanks once again for the package, Max!

Best,

Bruno

mboeck11 commented 3 years ago

Hi,

thanks for spotting this error, Bruno! Actually, there is no object y, thus the error pops up. Should be fixed and new version on GitHub.

Best, Max

bttomio commented 3 years ago

Thanks a lot, Max!