此 R 代码会引发错误,即
.xts(e, .index(e1), .indexCLASS = indexClass(e1), .indexFORMAT = indexFormat(e1), 中的错误:索引长度必须与观察数匹配
代码:
library('quantmod')
library('foreach')
JNK <- getSymbols('JNK', from='2010-01-01',auto.assign=FALSE)[,6]
GSPC <- getSymbols('^GSPC', from='2010-01-01',auto.assign=FALSE)[,6]
JNK <- diff(log(JNK))
GSPC <- diff(log(GSPC))
Data <- na.omit(merge(JNK,GSPC, all=FALSE))
m <- lm(JNK ~ GSPC, data=Data)
plot(m)
谁能帮我弄清楚我做错了什么?