我尝试对某些 xts
数据运行 auto.arima
,但收到以下错误:
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
、向量
或矩阵
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/