我正在尝试对某些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转换为vectormatrixauto.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/

10-12 19:23