R/Psi.varest.R

"Psi.varest" <-
function(x, nstep=10, ...){
  if(!is(x, "varest")){
    stop("\nPlease provide an object of class 'varest', generated by 'VAR()'.\n")
  }
  nstep <- abs(as.integer(nstep))
  Phi <- Phi(x, nstep = nstep)
  Psi <- array(0, dim=dim(Phi))
  params <- ncol(x$datamat[, -c(1:x$K)])
  sigma.u <- crossprod(resid(x)) / (x$obs - params)
  P <- t(chol(sigma.u))
  dim3 <- dim(Phi)[3]
  for(i in 1:dim3){
    Psi[, , i] <- Phi[, , i] %*% P
  }
  return(Psi)
}

Try the vars package in your browser

Any scripts or data that you put into this service are public.

vars documentation built on March 31, 2023, 10:30 p.m.