thirfBand <- function(mcout,Tsigbrk, ...) { require(tensor) ndraw <- dim(mcout)[1] irf <- array(0, c(v=2,shock=2,t=40, country=6, draw=ndraw)) for (it in 1:ndraw) { A0 <- matrix(mcout[it, 1:4], nrow=2) lmd <- matrix(mcout[it, 5:14] , nrow=2) lmd <- cbind(lmd[ , 1:4], c(0,0), lmd[ ,5]) lmd <- exp(-.5 * lmd) svhout <- SVARhtskdmdd( A0=A0, lmd=lmd, Tsigbrk=Tsigbrk, ...) Aplus <- svhout$var$By sqrtxxi <- apply(svhout$var$xxi, 3, chol) sqrtxxi <- array(sqrtxxi, c(4,4,2)) Aplusdraw <- array(rnorm(8), c(4,2)) for ( iv in 1:2) Aplusdraw[ , iv] <- crossprod(sqrtxxi[ , , iv], Aplusdraw[ , iv]) Aplusdraw <- Aplus + array(Aplusdraw, c(2,2,2)) A0i <- solve(A0) By <- tensor(A0i, Aplusdraw, 2, 1) irfbase <- impulsdtrf(vout=list(By=By), smat=A0i) for (ic in 1:6) { irf[ , , , ic, it] <- aperm(tensor(irfbase, diag(lmd[ , ic]), 2, 1), c(1,3,2)) } } return(irf) }