# Modeling a time series using various approaches (including auto.arima() in package forecast)

I have tried to model a time series (https://dl.dropboxusercontent.com/u/13029929/ts.txt) with various approaches, but haven't been satisfied. The original time series and its ACF and PACF look like 1. It doesn't look weakly stationary to me, because the mean and variance don't seem constant. I want to test its stationarity by the augmented Dickey-Fuller test, but the test gives a very small p-value, rejecting the existence of a unit root. (I wonder if I misuse the adfTest() function?)

adfTest(tmp,lags=20,type=c("c"))

Title:  Augmented Dickey-Fuller Test

Test Results:   PARAMETER:
Lag Order: 20   STATISTIC:
Dickey-Fuller: -12.4317   P VALUE:
0.01

Description:  Thu May  1 00:47:45 2014 by user:

Warning message: In adfTest(tmp, lags = 20, type = c("c")) :
p-value smaller than printed p-value


Its ACF and PACF seem to suggest a AR(20) model, so I fit it with AR(20), but the residual series didn't pass Ljung-Box test (p-value = 1.11e-15):

out = arima(tmp, order=c(20,0,0))

Box.test(out$residuals, lag = max(log(length(tmp)), 20)+10, fitdf = 20, type = "Ljung-Box")  2. Because the series doesn't look stationary to me, I then difference the series once, and the differenced series seems to have constant mean, although still nonconstant variance. It looks like a MA(6) process, but after fitting MA(6), the p-value of Ljung-Box test on the residual series is still too small (p-value < 2.2e-16) 3. I then think of taking logarithm of the original series, to reduce variability: and then difference the logarithm of the original series (see below): I am not sure if it is worth to take the logarithm, and what models to try with the differenced logarithm series, as I tried several ARMA models on it, the residual series doesn't pass the Ljung-Box test. 4. I tried auto.arima() in package forecast written by Prof Hyndman, on my time series. It suggests ARIMA(3,1,3), while, suprisingly, my adfTest doesn't say the series has unit root (see part 1). But the residual series still has spikes, and doesn't pass Ljung-Box test out1 = auto.arima(tmp) out1 Series: tmp ARIMA(3,1,1) Coefficients: ar1 ar2 ar3 ma1 0.9747 -0.2607 0.1460 -0.9811 s.e. 0.0063 0.0081 0.0061 0.0020 sigma^2 estimated as 0.1172: log likelihood=-9881.62 AIC=19773.24 AICc=19773.25 BIC=19814.53  Box.test(out1\$residuals, lag = max(log(length(out1\$residuals)), 4)+10, fitdf = 4, type = "Ljung-Box") Box-Ljung test data: out1$residuals
X-squared = 61.8217, df = 16.257, p-value = 3.101e-07


The residual series and its ACF look like: 5. It is similar to apply auto.arima() to logarithm of the original time series, which suggests ARIMA(3,1,3)

I really appreciate if you could suggest some models (and transforms on the original series) to try. Thanks!

• Clearly nonstationary even from just the time series plot of the data. The log-scale data is still very skew. The differences of the logs look very "bursty", with periods of high variance, but I don't know that say a GARCH model on the differences of the logs is the right answer either. It looks to me like there's a lot going on there in the mean, but I don't have a sense for the likely properties of the thing being modelled. – Glen_b May 1 '14 at 8:32
• I uploaded my time series data here, and updated my post with that. – Tim May 1 '14 at 10:46
• @Glen_b: thanks. if I model a time series by GARCH, should the time series be uncorrelated? In other words, a GARCH process must be uncorrelated? In my example, I would like to apply GARCH to the residual series from those approaches I tried above, but the residual series didn't pass Ljung-Box test, meaning that the null that the residual series is uncorrelated is rejected. – Tim May 1 '14 at 10:48
• GARCH generalizes ARCH (which you might start with), by adding more lag terms in the model for the heteroskedasticity in the errors. As explained here, you start with an AR model on the data (presumably on the differenced logs in your case), but you could have that be AR(0) or AR(1) or AR(3) or whatever on the data, before modelling the $\epsilon_t$. ... ctd – Glen_b May 1 '14 at 15:34
• ctd ... See also the description of GARCH(p,q). It might at least be worth considering an ARCH model. – Glen_b May 1 '14 at 15:38