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?