【问题标题】:Using auto.arima on xts objects在 xts 对象上使用 auto.arima
【发布时间】:2012-12-02 23:24:54
【问题描述】:

我正在尝试对一些 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() 不要报错。

【问题讨论】:

  • 如果不行,不要使用xts对象,而是通过coredata()导出到矩阵,可能用as.data.frame()转换。

标签: r xts


【解决方案1】:

我建议你在auto.arima的参数列表中将GSPC$GSPC.Close转换为tsvectormatrix

auto.arima(as.ts(Cl(GSPC)))
auto.arima(coredata(Cl(GSPC)))  # Dirk's suggestion

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-06-15
    • 2014-12-25
    • 1970-01-01
    • 2021-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多