The Augmented Dickey-Fuller Test
The Augmented Dickey-Fuller (ADF) test is the workhorse hypothesis test for stationarity, and the first concrete decision in the Box-Jenkins ARIMA workflow. Rather than survey it top-down, this page builds up from the underlying idea of stationarity to the full test.
Stationarity and why it matters
A series is weakly (covariance) stationary if its mean, variance, and autocovariances do not change over time. Intuitively, the series looks statistically "the same" no matter which window you view it through.
Why it matters: classical models (ARIMA, exponential smoothing, VAR) are built on this assumption. On a non-stationary series, the sample mean and sample autocorrelations are not estimating fixed population quantities, so coefficient estimates are unstable and forecasts diverge. Establishing stationarity (or manufacturing it by differencing) is therefore step zero of any classical forecasting pipeline.
Stationarity as a polynomial-root condition
This is the key insight that makes the whole test possible: stationarity of an autoregressive process is decided entirely by the roots of a polynomial.
Write an AR() process with the backshift operator (where ):
The characteristic equation is . The process is stationary if and only if every root of lies strictly outside the unit circle in the complex plane, i.e. for all roots.
So "is this series stationary?" is, mathematically, the same question as "do all the roots of this polynomial sit outside the unit circle?"
The unit root
A unit root is the boundary case of the rule just described: one of the roots sits exactly on the unit circle, . That single fact is what "non-stationary" means in the ADF world.
Note that being a root is equivalent to a simple condition on the coefficients:
The ADF test exists precisely to answer one yes/no question: does the series have a unit root? If yes → non-stationary; if no → stationary (at least with respect to this unit-root form of non-stationarity).
The simplest case: AR(1)
For AR(1): , the characteristic polynomial is , whose single root is .
| Condition | Root location | Behaviour |
|---|---|---|
| (outside) | Stationary: shocks decay geometrically, series is mean-reverting | |
| (on the circle) | Unit root: pure random walk ; shocks are permanent | |
| (inside) | Explosive: series diverges; rare in practice |
When the series becomes a random walk: each shock is added to a running sum and never decays. The variance grows without bound, the mean wanders, and the ACF decays linearly rather than geometrically. This is the canonical non-stationarity the ADF test is built to detect.
Why differencing removes a unit root
Because a unit root factors out cleanly. If has a single root at , we can write , where has all roots outside the circle. The factor corresponds exactly to the differencing operator .
So applying one difference cancels the unit root, leaving the stationary process .
This is why ARIMA has an 'I'
The number of unit roots equals the differencing order — the Integrated part of ARIMA. Each difference removes one unit root and brings the series one step closer to stationarity. That is the entire job of the ADF test inside Box-Jenkins: find the smallest that removes every unit root.
The ADF regression
Testing "" directly is awkward because under the null the usual regression theory breaks down (the regressor is itself non-stationary). Dickey and Fuller's trick is to subtract from both sides of the AR(1) equation:
The full ADF regression adds deterministic terms and lagged differences (the "augmented" part, explained below):
The reparameterisation turns the unit-root question into a question about a single coefficient .
Null and alternative hypotheses
From the reparameterisation above, with :
- → unit root, non-stationary → null hypothesis
- → stationary, mean-reverting → alternative
Two consequences worth internalising:
- The unit root is the null. The test is set up to assume non-stationarity and demand evidence to overturn it. This asymmetry drives the interpretation of the p-value and the "fail to reject" outcome discussed later.
- It is a one-sided test. Stationarity only ever pushes negative, so we only look at the left tail.
The "Augmented" part
The plain Dickey-Fuller regression assumes the errors are white noise. Real series have higher-order autocorrelation, which would contaminate the estimate of . The augmented test soaks up that structure by adding lagged differences as control regressors — the term in the boxed regression above.
These terms whiten the residuals so that the distribution of the test statistic
is valid. The lag order is chosen to remove residual autocorrelation —
commonly by minimising AIC/BIC (statsmodels' autolag="AIC") or a rule of thumb
like .
The three test specifications
The deterministic terms (drift) and (trend) define three flavours of the test. You must match the specification to the visual shape of your series, because it changes the critical values:
| Spec | Regression includes | Use when the series… | statsmodels regression= |
|---|---|---|---|
| n | only | fluctuates around zero | "n" |
| c | fluctuates around a non-zero constant | "c" (default) | |
| ct | has a linear trend | "ct" |
Match the spec to the data
Using the wrong deterministic terms is the most common ADF mistake. Run a
trend-stationary series through the no-trend ("c") spec and the leftover trend
masquerades as a unit root — the test fails to reject when it should. If your
plot shows a clear upward drift, use "ct". Otherwise the trend leaks into the
residuals and biases the test toward non-stationarity.
The test statistic and its distribution
The ADF statistic is the t-ratio on :
Here is the subtlety that catches everyone: under the null this statistic does NOT follow a Student's distribution. Because is non-stationary under , the estimator has a non-standard limiting distribution (a functional of Brownian motion — the Dickey-Fuller distribution). It is skewed and shifted to the left, so the critical values are more negative than the familiar :
| Spec | 1% | 5% | 10% |
|---|---|---|---|
| c (constant) | |||
| ct (constant + trend) |
(approximate large-sample MacKinnon values; statsmodels returns exact sample-size-adjusted ones.)
You reject the unit-root null when the ADF statistic is more negative than the critical value (it falls in the left tail). A statistic of does not reject; rejects decisively.
Interpreting the p-value
The ADF p-value is computed by interpolating the test statistic against the Dickey-Fuller distribution (MacKinnon's response-surface approximation, not a -table). Concretely:
It answers: if the series truly had a unit root, how often would we see a this far below zero by chance alone? A small p-value means "rarely" — so a unit root is implausible, and we conclude the series is stationary.
The decision rule and setting d in ARIMA
| p-value | Interpretation | ARIMA action |
|---|---|---|
| Reject unit root; series is stationary | Current is enough | |
| Cannot reject unit root; likely non-stationary | Difference once more, , re-test |
The recipe for choosing is just this rule in a loop: test the raw series; if it fails to reject, difference and re-test; the number of differences needed to finally reject is exactly the integration order in ARIMA.
Why "fail to reject" is weaker than "proven stationary"
Because the unit root is the null hypothesis, the two outcomes are not symmetric.
'Fail to reject' is not 'proven stationary'
Failing to reject only means there isn't enough evidence against a unit root — it never confirms one, and rejecting never proves perfect stationarity. The ADF test also has notoriously low power: when is close to but below 1 (say ), a near-unit-root stationary series is easily mistaken for a random walk, so stays above even though the series is technically stationary.
This low power is the practical reason you should not rely on the ADF test alone — which motivates pairing it with the KPSS test below.
How the KPSS test complements ADF
The KPSS test flips the hypotheses: KPSS takes stationarity as its null. Reading the two tests together resolves the ambiguity that low power introduces:
| ADF | KPSS | Conclusion |
|---|---|---|
| Reject (stationary) | Fail to reject (stationary) | Stationary ✓: both agree |
| Fail to reject | Reject | Non-stationary (unit root): both agree |
| Fail to reject | Fail to reject | Inconclusive: not enough data/power |
| Reject | Reject | Difference-and-trend mix: try detrending; possible structural break |
When both agree you can act with confidence; when they disagree, the disagreement itself is diagnostic.
What the ADF test misses
What the ADF test will not catch
The ADF test detects only unit-root non-stationarity (a random-walk-type stochastic trend). It does not detect: structural breaks (a sudden level shift in 2008), heteroscedasticity (variance changing over time), or seasonality. A series can pass the ADF test and still be badly non-stationary in a way it was never designed to catch. Always complement the number with a plot.
A worked example
Take a series with a clear upward trend (36 monthly observations, levels ~50→110).
ADF on the raw levels (spec "ct", because there is a visible trend):
ADF statistic: −1.83 p-value: 0.36
5% critical value: −3.41
The statistic is less negative than the critical value, and → fail to reject → the series has a unit root.
Apply one difference and re-test (now spec
"c", since differencing removed the trend):
ADF statistic: −5.71 p-value: 0.0000
5% critical value: −2.86
Now is far into the left tail and → reject → the differenced series is stationary. One difference removed one unit root, so . We can now fit the ARMA part of an ARIMA model on .
The same workflow in Python
import numpy as np
from statsmodels.tsa.stattools import adfuller, kpss
# A trending (non-stationary) series: random walk with drift
rng = np.random.default_rng(0)
y = 50 + np.cumsum(2.0 + rng.normal(0, 3, size=120))
def report_adf(series, regression="c", label=""):
stat, pval, used_lag, nobs, crit, icbest = adfuller(
series, regression=regression, autolag="AIC"
)
print(f"[{label}] ADF={stat:.3f} p={pval:.4f} lags={used_lag}")
for k, v in crit.items():
print(f" {k:>3} critical value: {v:.3f}")
print(" →", "STATIONARY (reject unit root)" if pval < 0.05
else "NON-STATIONARY (fail to reject)")
# Levels: include a trend term because the series drifts upward
report_adf(y, regression="ct", label="levels")
# First difference: trend is gone, use the constant spec
report_adf(np.diff(y), regression="c", label="Δy")
# Cross-check with KPSS (null = stationary), the complementary test
kpss_stat, kpss_p, _, kpss_crit = kpss(np.diff(y), regression="c", nlags="auto")
print(f"\nKPSS on Δy: stat={kpss_stat:.3f} p={kpss_p:.4f} "
f"→ {'stationary' if kpss_p > 0.05 else 'non-stationary'}")
# Helper: difference until ADF rejects → returns the integration order d
def integration_order(series, max_d=2, alpha=0.05):
s = np.asarray(series, dtype=float)
for d in range(max_d + 1):
p = adfuller(s, autolag="AIC")[1]
if p < alpha:
return d, p
s = np.diff(s)
return max_d, p
d, p = integration_order(y)
print(f"\nChosen differencing order: d = {d} (ADF p = {p:.4f})")
Related concepts
- Time Series Fundamentals: stationarity, differencing, and where the ADF test first appears
- ARIMA Models: the test selects the integration order in ARIMA
- ARIMA Order Selection: the full Box-Jenkins workflow that begins with this test
- Hypothesis Testing: null/alternative, p-values, and the meaning of "fail to reject"