8
$\begingroup$

I am using python for time-series analysis of count data and came across a problem where I have a time-series that to me looks non-stationary but the Augmented Dickey-Fuller test (implemented in statsmodels) rejects the null hypothesis quite strongly and thus suggests the time-series is stationary.

Here are the specifics: I have included a plot of the time-series below as well as the raw data. Time Series in Question Raw Data:

[17.0, 1.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 20.0, 866.0, 5386.0, 295.0, 452.0, 227.0, 632.0, 2821.0, 989.0, 1244.0, 934.0, 1462.0, 541.0, 2030.0, 573.0, 1191.0, 466.0, 585.0, 3045.0, 3386.0, 3354.0, 2310.0, 4094.0, 3850.0, 4800.0, 1082.0, 1032.0, 247.0, 1830.0, 3912.0, 2959.0, 2157.0, 1741.0, 1231.0, 1099.0, 60.0, 14.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 7.0, 2.0, 0.0, 0.0, 0.0, 7.0, 0.0, 4.0, 1.0, 2.0, 30.0, 43.0, 241.0, 147.0, 26.0, 94.0, 4.0, 9.0, 3.0, 3.0, 9.0, 11.0, 21.0, 13.0, 5.0, 9.0, 21.0, 17.0, 52.0, 23.0, 1489.0, 646.0, 1515.0, 589.0, 623.0, 143.0, 77.0, 11.0, 25.0, 124.0, 74.0, 197.0, 72.0, 199.0, 963.0, 1058.0, 310.0, 866.0, 537.0, 502.0, 248.0, 786.0, 655.0, 667.0, 864.0, 336.0, 126.0, 127.0, 58.0, 70.0, 43.0, 836.0, 49.0, 38.0, 137.0, 194.0, 157.0, 5.0, 9.0, 60.0, 84.0, 21.0, 17.0, 4.0, 2.0, 9.0, 433.0, 284.0, 6.0, 22.0, 25.0, 42.0, 33.0, 6.0, 1.0, 8.0, 15.0, 27.0, 19.0, 220.0, 415.0, 96.0, 210.0, 449.0, 15.0, 49.0, 173.0, 842.0, 290.0, 59.0, 10.0, 2.0, 5.0, 0.0, 0.0, 0.0, 20.0, 11.0, 50.0, 39.0, 139.0, 15.0, 19.0, 16.0, 30.0, 6.0, 9.0, 15.0, 291.0, 53.0, 65.0, 148.0, 845.0, 157.0, 33.0, 33.0, 14.0, 14.0, 91.0, 113.0, 91.0, 513.0, 187.0, 54.0, 5.0, 4.0, 2.0, 1.0, 2.0, 0.0, 2.0, 4.0, 3.0, 243.0, 90.0, 35.0, 67.0, 134.0, 590.0, 462.0, 159.0, 45.0, 5.0, 0.0, 1.0, 0.0, 0.0, 2.0, 0.0, 4.0, 25.0, 8.0, 46.0, 18.0, 32.0, 1431.0, 98.0, 1648.0, 1056.0, 3938.0, 8227.0, 915.0, 565.0, 762.0, 529.0, 1776.0, 384.0, 127.0, 11.0, 30.0, 1591.0, 462.0, 111.0, 349.0, 4154.0, 1355.0, 412.0, 485.0, 419.0, 713.0, 1098.0, 668.0, 139.0, 460.0, 966.0, 1543.0, 317.0, 475.0, 162.0, 880.0, 376.0, 333.0, 541.0, 313.0, 301.0, 89.0, 238.0, 122.0, 633.0, 186.0, 62.0, 38.0, 9.0, 951.0, 5.0, 450.0, 36.0, 20.0, 36.0, 28.0, 3.0, 12.0, 2.0, 3.0, 1.0, 2.0, 5.0, 14.0, 8.0, 19.0, 38.0, 59.0, 23.0, 31.0, 174.0, 16.0, 28.0, 69.0, 26.0, 141.0, 8.0, 10.0, 6.0, 3.0, 1.0, 33.0, 11.0, 8.0, 519.0, 138.0, 43.0, 694.0, 379.0, 864.0, 37.0, 39.0, 27.0, 5.0, 59.0, 24.0, 15.0, 10.0, 6.0, 8.0, 39.0]

And here is the results of the Augmented Dickey-Fuller from statsmodels:

ADF Statistic: -4.191

Corresponding p-value: 0.00068

My question really boils down to:

  1. Am I doing the analysis wrong (i.e., do you get a different answer or am I using the test inappropriately?) or interpreting the results wrong?
  2. If I am interpreting this correctly, can someone give me some intuition for why the above time-series is stationary? To me it looks like the variance and the expected value would not be constant throughout the time-series.
$\endgroup$
2
  • 2
    $\begingroup$ I don't see why you think it must be non-stationary in mean. It looks like volatility clustering but mean stationary to me. $\endgroup$
    – Aksakal
    Commented Aug 25, 2015 at 18:41
  • $\begingroup$ When I say it does not look stationary in mean I think that perhaps those 'clusters of volatility' are sections with a different mean than the rest of the time-series. But that is just a hunch. Either way, clusters of volatility would imply non-stationary in variance right? Or is this heteroscedasticity? $\endgroup$
    – jds
    Commented Aug 25, 2015 at 19:36

2 Answers 2

7
$\begingroup$
  1. I didn't replicate your analysis, but it's surely possible to reject the Null of the ADF test with a process like this (also note that these tests are notorious for having low statistical power). I would recommend fitting an AR(1) model to the data as a sanity check- this is basically what you are doing with the ADF test, but you can get a better idea of what sort of AR(1) coefficient is being estimated, and whether or not this coefficient is near unit-root (close to 1). Remember, ADF tests for a unit root, not for stationarity per say. A process is (covariance) stationary if it has time-invariant 1st and 2nd moments. So it looks like the variance may not be constant, while the process could be stationary in the mean. For example, stock market returns usually reject the ADF test, and we assume they are stationary, though we know squared returns tend to cluster.

  2. Note that ADF tests for (or absence of) a unit root in the data process through autoregressive procedures. If the test is rejecting the null, then its more likely that your process has an AR(1) coefficient less than 1, aka, the process is being estimated as mean reverting, so the best guess for next period's value is not necessarily the previous period's value, but rather a value that is shrunken towards the mean of the process.

Statistical test results, including ADF, are not the end all be all - they are tests and can never prove anything with 100% certainty - they just provide evidence for/against some hypothesis. Lastly, you could specify the mean of the process and model the variance as a GARCH process, but your limited sample size would be a concern when estimating such models.

ADF Test: https://en.wikipedia.org/wiki/Dickey%E2%80%93Fuller_test

AR Models: https://en.wikipedia.org/wiki/Autoregressive_model

(G)ARCH Processes: https://en.wikipedia.org/wiki/Autoregressive_conditional_heteroskedasticity

$\endgroup$
3
  • 1
    $\begingroup$ This was very helpful. In response to your comment about power of the test: please correct me if I am wrong but power would not be my problem as the ADF is rejecting the null hypothesis. Furthermore I believe that the test is fairly specific and as such I should be fairly confident that there is in fact no unit root. $\endgroup$
    – jds
    Commented Aug 25, 2015 at 21:17
  • $\begingroup$ Hi Justin - I was just mentioning to be wary of ADF tests (an more generally, tests for stationarity) because of their lower statistical power (statistical power refers to the probability the null was correctly rejected) - Still, it doesn't hurt to use these tests, or even multiple tests. What is just as important in my opinion is knowing what to look for when visualizing a time series and being able to tell, from experience and understanding, whether a process looks convincingly mean-reverting or not. $\endgroup$
    – RA334
    Commented Aug 26, 2015 at 14:20
  • 1
    $\begingroup$ Also yes I'd say its safe to claim that since the hypothesis was rejected, this suggests evidence in favor of the process not having a unit root. You may want to try other tests for unit roots / stationarity for some reinforcment: Augmented Dickey–Fuller (ADF) test Elliott–Rothenberg–Stock test KPSS unit root test Phillips–Perron test Schmidt–Phillips test Zivot–Andrews $\endgroup$
    – RA334
    Commented Aug 26, 2015 at 14:24
5
$\begingroup$

Take a look at the graph of the differences of your series here. It looks like volatility clustering with a stationary mean to me. I'd try something like GARCH or stochastic volatility.

enter image description here

The other thing to note is that it appears that your jumps up are faster than drops down. This would suggest a threshold model, maybe nonlinear.

finally, if you draw a histogram then clearly normal distribution is not a good fit, so you may look for non-gaussian errors.

enter image description here

UPDATE: As in my comment, you may try testing your series for heteroscedastisicty, because ADF test will not catch it. There are tests such as Engle's ARCH test. It rejects the homoscedasticity for both levels and differences.

$\endgroup$
4
  • $\begingroup$ This is all very helpful, but what about the variance and the ultimate question of stationarity? Wouldn't this suggest that the series is non-stationary (or at least not covariance-stationary) because the variance is not constant? $\endgroup$
    – jds
    Commented Aug 25, 2015 at 20:26
  • $\begingroup$ Somewhat in response to my own question I found this (stats.stackexchange.com/questions/131054/…) which describes that the ADF test is not equivalent to testing for covariance stationarity. It only tests for trend stationarity. So in reality my time-series may not be covariance stationary but the ADF test just will not pick that type of non-stationarity up. Correct? $\endgroup$
    – jds
    Commented Aug 25, 2015 at 20:38
  • 1
    $\begingroup$ It appears that variance is not stationary, right, that's what I meant by clustering. So, yes, you may call the series non-stationary in this regard, and ADF test won't catch this. You may try other tests like Engle's arch test, it will reject it on both the levels and differences. $\endgroup$
    – Aksakal
    Commented Aug 25, 2015 at 20:39
  • $\begingroup$ To be precise, (G)ARCH-type patterns in conditional variance do not imply that the conditional variance in nonstationary, even though they do imply that the conditional variance is nonconstant. $\endgroup$ Commented Oct 18, 2015 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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