我正在尝试运行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
Run Code Online (Sandbox Code Playgroud)
我发现如果我
close <- as.ts(GSPC$GSPC.Close)
Run Code Online (Sandbox Code Playgroud)
然后auto.arima不会返回错误.但后来我丢失了与该xts对象相关的日期信息.有没有办法将数据保持为xts仍然运行该功能?
我注意到,例如acf(GSPC$GPSC.Close),pacf()不要给出错误.
我建议您在 的参数列表中转换GSPC$GSPC.Close为ts, vector, 或:matrixauto.arima
auto.arima(as.ts(Cl(GSPC)))
auto.arima(coredata(Cl(GSPC))) # Dirk's suggestion
Run Code Online (Sandbox Code Playgroud)