liveBook · Manning

Augmented dickey–fuller test

As explained in Statistics Every Programmer Needs

The Augmented Dickey–Fuller test is a statistical test for a unit root and the associated nonstationarity of a time series, with lagged difference terms included to accommodate autocorrelation.

The Augmented Dickey–Fuller (ADF) test evaluates whether a time series is stationary or contains a unit root associated with nonstationarity. It accommodates autocorrelation by adding lagged difference terms to the regression. section 7.3.7

Interpret the test through its hypotheses and practical limitations:

  • Treat nonstationarity as the null hypothesis; reject it when the p-value falls below the typical 5% threshold. section 7.3.7
  • Include a constant, optional time trend, lagged levels, lagged differences, and an error term in the estimated regression. section 7.3.7
  • Treat lag selection as consequential because it can change results; expect lower power with short or noisy series. section 7.3.7

Testing prices before and after differencing

Applying statsmodels' adfuller to Apple closing prices produces a p-value of 0.5761, so the nonstationarity null is not rejected. After first-order differencing, the p-value becomes 1.25e-16, supporting stationarity. section 7.3.7

>>> from statsmodels.tsa.stattools import adfuller
>>> adf_test = adfuller(train)
>>> print('p-value:', adf_test[1])
p-value: 0.5761116196186049

Run the ADF test with statsmodels and inspect the returned p-value. section 7.3.7

How Statistics Every Programmer Needs covers it

How deep it goes
Explains the null hypothesis, regression components, interpretation threshold, and lag-related limitations, without developing formal proof.
Examples
Uses Apple closing prices, first-order differencing, ACF/PACF comparisons, and statsmodels p-values.
What it assumes
Assumes familiarity with time series, autocorrelation, p-values, and differencing while defining the test’s main terms.
What you can do after
Diagnose nonstationarity with statsmodels and evaluate whether differencing produces a stationary series.
How it connects
Connects stationarity with nonstationarity, unit roots, autocorrelation, differencing, ACF, and PACF.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Every Programmer Needs. The section links point to the parts of the book it draws on.