我正在尝试对某些auto.arima
数据运行xts
,但是遇到以下错误:
library(quantmod)
library(forecast)
getSymbols('^GSPC',from='2000-01-01')
auto.arima(GSPC$GSPC.Close)
Error in dimnames(cd) <- list(as.character(index(x)), colnames(x)) :
'dimnames' applied to non-array
我发现如果我
close <- as.ts(GSPC$GSPC.Close)
则
auto.arima
不返回错误。但是后来我丢失了与xts
对象关联的日期信息。有没有一种方法可以将数据保留为xts
并仍运行该函数?我注意到例如
acf(GSPC$GPSC.Close)
和pacf()
不给出错误。 最佳答案
我建议您在GSPC$GSPC.Close
的参数列表中将ts
转换为vector
,matrix
或auto.arima
:
auto.arima(as.ts(Cl(GSPC)))
auto.arima(coredata(Cl(GSPC))) # Dirk's suggestion
关于r - 在XTS对象上使用auto.arima,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13887507/