jaredwoodard
jaredwoodard

Reputation: 947

Using auto.arima on xts objects

I'm trying to run auto.arima on some xts data, but am getting the following error:

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

I found that if I

close <- as.ts(GSPC$GSPC.Close)

then auto.arima does not return the error. But then I've lost the date information associated with the xts object. Is there a way to keep the data as xts and still run the function?

I noticed that e.g. acf(GSPC$GPSC.Close) and pacf() do not give errors.

Upvotes: 7

Views: 4095

Answers (1)

Joshua Ulrich
Joshua Ulrich

Reputation: 176648

I suggest you convert GSPC$GSPC.Close to a ts, vector, or matrix in the argument list of auto.arima:

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

Upvotes: 2

Related Questions