Error in VAR estimation probably in roots function of vars pachange
Dear participants , I have a data set with 16 parameters and 2515 observations. My problem is with correlation matrices. I have checked for empty cells, NAs and zeros with (Y[!is.na(Y)])
I get an error when I run the following code:
Y <- mydata in csv
t <- nrow(Y)
k <- ncol(Y)
space <- 200
CV <- array(NA, c(k, k, (t-space)))
colnames(CV) = rownames(CV) = colnames(Y)
for (i in 1:dim(CV)[3]) {
var1 <- VAR(Y[i:(space+i-1),], p=nlag, type="const")
if(any(roots(var1)>1)){
CV[,,i] <- CV[,,(i-1)]
} else {
CV[,,i] <- gfevd(var1, n.ahead=nfore)$fevd
}
if (i%%500==0) {print(i)}
}
The error I get is the following:
"Error in eigen(companion) : infinite or missing values in 'x' ".
It should compute for each i and j element in k by k matrix.