2
$\begingroup$

I must be doing something very wrong here, as auto.arima in R is completely dying, but I can't see what it is. I have the latest version of forecast and R and I think this happens on both Windows and Unix. It works for some/most time series I tried (equities) but fails for others. It seems to fail more often when I diff the high/low with the previous day's close as opposed to just diffing the closes as below. Is this a bug or am I somehow giving arima bad data? (and causing it to die with a horrible error message) I tried searching for this error but didn't come up with much. Thanks a lot.

library(tseries)
library(forecast)
dwa <- get.hist.quote(instrument="DWA", start="2010-01-01", end="2013-10-31")
logreturns <- diff(log(dwa$Close))*100 
fit <- auto.arima(logreturns, trace=TRUE)

Output:

This is forecast 4.8 

trying URL 'http://chart.yahoo.com/table.csv?s=DWA&a=0&b=01&c=2010&d=9&e=31&f=2013&g=d&q=q&y=0&z=DWA&x=.csv'
Content type 'text/csv' length unknown
opened URL
.......... .......... .......... .......... ....
downloaded 44 Kb

time series starts 2010-01-04
time series ends   2013-10-07

 ARIMA(2,1,2) with drift         : 1e+20 *
 ARIMA(0,1,0) with drift         : 1e+20 *
 ARIMA(1,1,0) with drift         : 1e+20 *
 ARIMA(0,1,1) with drift         : 1e+20 *
 ARIMA(1,1,2) with drift         : 1e+20 *
 ARIMA(3,1,2) with drift         : 1e+20 *
 ARIMA(2,1,1) with drift         : 1e+20 *
 ARIMA(2,1,3) with drift         : 1e+20 *
 ARIMA(1,1,1) with drift         : 1e+20 *
 ARIMA(3,1,3) with drift         : 1e+20 *
 ARIMA(2,1,2)          : 1e+20 *Error in if (diffs == 1 & constant) { : argument is of length zero
Calls: auto.arima -> myarima
In addition: Warning messages:
1: In if (is.constant(x)) { :
  the condition has length > 1 and only the first element will be used
2: In if (is.constant(x)) return(d) :
  the condition has length > 1 and only the first element will be used
3: In if (is.constant(dx)) { :
  the condition has length > 1 and only the first element will be used
Execution halted
$\endgroup$
  • 1
    $\begingroup$ The AIC values are abnormally high, so I would suspect bad data. $\endgroup$ – mpiktas Oct 8 '13 at 15:28
  • $\begingroup$ As @forecaster has pointed out, the problem is that auto.arima expects a ts object, not a zoo object. However, the error message is very unfriendly. I'll catch it more cleanly in the next version. $\endgroup$ – Rob Hyndman Oct 8 '13 at 22:42
3
$\begingroup$

@Aaron, your timeseries data is discontinous. auto.arima as many other forecast methods in R requires equally spaced time series.

The problem is your time series is not equally spaced, meaning there are gaps in the dates.

The following code converts the time series into a vector, and now the auto.arima works fine.

If you have seasonality in the data and you might want to clean the dataset and make it equally spaced time series.

library(tseries)
library(forecast)
dwa <- get.hist.quote(instrument="DWA", start="2010-01-01", end="2013-10-31")
logreturns <- diff(log(dwa$Close))*100
logreturns_nots = unclass(logreturns) ## converst time series into a vector.
fit <- auto.arima(logreturns_nots, trace=TRUE)

following is the result:

 ARIMA(2,1,2) with drift         : 4206.508
 ARIMA(0,1,0) with drift         : 4849.189
 ARIMA(1,1,0) with drift         : 4567.961
 ARIMA(0,1,1) with drift         : 1e+20
 ARIMA(1,1,2) with drift         : 1e+20
 ARIMA(3,1,2) with drift         : 4196.642
 ARIMA(3,1,1) with drift         : 4204.641
 ARIMA(3,1,3) with drift         : 1e+20
 ARIMA(2,1,1) with drift         : 4213.613
 ARIMA(4,1,3) with drift         : 1e+20
 ARIMA(3,1,2)                    : 4194.541
 ARIMA(2,1,2)                    : 4204.487
 ARIMA(4,1,2)                    : 1e+20
 ARIMA(3,1,1)                    : 4202.653
 ARIMA(3,1,3)                    : 1e+20
 ARIMA(2,1,1)                    : 4211.68
 ARIMA(4,1,3)                    : 1e+20

 Best model: ARIMA(3,1,2)
$\endgroup$
  • $\begingroup$ Thanks very much for your answer. I will look into cleaning/deseasonalizing as you suggest. I am trying to learn about this stuff. $\endgroup$ – Aaron Oct 9 '13 at 3:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.