0

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.

Oli
  • 7,903
  • 3
  • 20
  • 42
  • 2
    Please give us a small snippet of your dataset with the dput() function. – Newl May 09 '19 at 12:22
  • I hate to be this person, but please have a look at this link of [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) . The answer is not so long, but very informative. Please insert your output as a code snippet with editing your original post. – Newl May 10 '19 at 14:17
  • updated https://stackoverflow.com/questions/56120041/vars-package-roots-command-error-in-eigencompanion-infinite-or-missing-val – sardor mirzaev May 15 '19 at 06:58

0 Answers0