Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using auto.arima on xts objects

Tags:

r

xts

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.

like image 610
jaredwoodard Avatar asked Dec 14 '12 23:12

jaredwoodard


People also ask

How good is auto ARIMA?

auto. arima() does not aim at being a magic wand. Its aim is to be a robust method that works reliably on a large number of time series, and it is very good at this. If you have subject matter knowledge that it does not model, then by all means, help it along.

Does auto ARIMA do differencing?

Auto. arima has the ability to decide whether or not the data used to train the model needs a seasonal differencing.

What does auto ARIMA do?

An autoregressive integrated moving average, or ARIMA, is a statistical analysis model that uses time series data to either better understand the data set or to predict future trends. A statistical model is autoregressive if it predicts future values based on past values.


1 Answers

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
like image 65
Joshua Ulrich Avatar answered Sep 28 '22 05:09

Joshua Ulrich