0

I am very new in R and statistics. I would like to perform the Johansen cointegration test for 75 columns by using a loop. And then to have the result as a data frame or a list sort out trace test and confidence levels 90% 95% 99% into data frame.

I have a time series in format data.frame. As I said, 75 columns with different names (company with daily data) and 495 rows.

According to ADF test time series are stationary.

So basically my data looks like: Name Name2 Name3 Name4 Name5 Name6 Name7 Name8 ... Name75
(all names are different)

I know that to get all possible combinations I have to use combn(), so I presume that my code should look like:

 combn(seq_len(ncol(myData)), 2,
         FUN=function(x) ca.jo(Farm2[, x[1]], Farm2[, x[2]]), simplify=FALSE)

Or may be something like :

for (col in colnames(myData)) {
  print(col)
  data <- myData[, col]
  print(data)
  Jo <- ca.jo(data, type="trace", K=2, ecdet="none", spec="longrun")
  summary(Jo)
}

But nothing is working.

Can someone help me understand and correct my loop?

Giora Simchoni
  • 3,487
  • 3
  • 34
  • 72

1 Answers1

0

Keep in mind that critical values are only reported for systems with less than 11 variables and are taken from Osterwald-Lenum, maybe you should consider restructuring your input data if you want to use Johansen test for cointegration in urca package.

Read more here.

Bud Damyanov
  • 30,171
  • 6
  • 44
  • 52
  • yes i know about less the 11 variables ...but I had that hope somehow to loop full data frame but in the same time to make it according to this "11 rule" – Ekaterina Cost Nov 19 '20 at 15:05