The Augmented Dickey-Fuller TestOpen in Colab

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 yty_t 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(pp) process with the backshift operator BB (where Byt=yt−1B y_t = y_{t-1}):

ϕ(B) yt=εt,ϕ(B)=1−ϕ1B−ϕ2B2−⋯−ϕpBp\phi(B)\, y_t = \varepsilon_t, \qquad \phi(B) = 1 - \phi_1 B - \phi_2 B^2 - \cdots - \phi_p B^p

The characteristic equation is ϕ(z)=0\phi(z) = 0. The process is stationary if and only if every root zz of ϕ(z)=0\phi(z)=0 lies strictly outside the unit circle in the complex plane, i.e. ∣z∣>1|z| > 1 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, z=1z = 1. That single fact is what "non-stationary" means in the ADF world.

Note that z=1z=1 being a root is equivalent to a simple condition on the coefficients:

ϕ(1)=1−ϕ1−ϕ2−⋯−ϕp=0.\phi(1) = 1 - \phi_1 - \phi_2 - \cdots - \phi_p = 0.

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): yt=ϕ yt−1+εty_t = \phi\, y_{t-1} + \varepsilon_t, the characteristic polynomial is 1−ϕz=01 - \phi z = 0, whose single root is z=1/ϕz = 1/\phi.

ConditionRoot locationBehaviour
∣ϕ∣<1\lvert\phi\rvert < 1∣z∣=1/∣ϕ∣>1\lvert z\rvert = 1/\lvert\phi\rvert > 1 (outside)Stationary: shocks decay geometrically, series is mean-reverting
ϕ=1\phi = 1z=1z = 1 (on the circle)Unit root: pure random walk yt=yt−1+εty_t = y_{t-1} + \varepsilon_t; shocks are permanent
∣ϕ∣>1\lvert\phi\rvert > 1∣z∣<1\lvert z\rvert < 1 (inside)Explosive: series diverges; rare in practice

When ϕ=1\phi = 1 the series becomes a random walk: each shock εt\varepsilon_t is added to a running sum and never decays. The variance Var⁡(yt)=tσ2\operatorname{Var}(y_t) = t\sigma^2 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 ϕ(z)\phi(z) has a single root at z=1z=1, we can write ϕ(z)=(1−z) ϕ~(z)\phi(z) = (1-z)\,\tilde\phi(z), where ϕ~\tilde\phi has all roots outside the circle. The factor (1−z)(1-z) corresponds exactly to the differencing operator Δ=1−B\Delta = 1 - B.

So applying one difference Δyt=yt−yt−1\Delta y_t = y_t - y_{t-1} cancels the unit root, leaving the stationary process ϕ~(B)Δyt=εt\tilde\phi(B)\Delta y_t = \varepsilon_t.

This is why ARIMA has an 'I'

The number of unit roots equals the differencing order dd — 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 dd that removes every unit root.

The ADF regression

Testing "ϕ=1\phi = 1" directly is awkward because under the null the usual regression theory breaks down (the regressor yt−1y_{t-1} is itself non-stationary). Dickey and Fuller's trick is to subtract yt−1y_{t-1} from both sides of the AR(1) equation:

yt−yt−1=(ϕ−1) yt−1+εt⟹Δyt=γ yt−1+εt,γ≡ϕ−1.y_t - y_{t-1} = (\phi - 1)\, y_{t-1} + \varepsilon_t \quad\Longrightarrow\quad \Delta y_t = \gamma\, y_{t-1} + \varepsilon_t, \qquad \gamma \equiv \phi - 1.

The full ADF regression adds deterministic terms and lagged differences (the "augmented" part, explained below):

  Δyt=α⏟drift+βt⏟trend+γ yt−1+∑j=1kδj Δyt−j+εt  \boxed{\;\Delta y_t = \underbrace{\alpha}_{\text{drift}} + \underbrace{\beta t}_{\text{trend}} + \gamma\, y_{t-1} + \sum_{j=1}^{k} \delta_j\, \Delta y_{t-j} + \varepsilon_t\;}

The reparameterisation turns the unit-root question into a question about a single coefficient γ\gamma.

Null and alternative hypotheses

From the reparameterisation above, with γ=ϕ−1\gamma = \phi - 1:

  • ϕ=1  ⟺  γ=0\phi = 1 \iff \gamma = 0 → unit root, non-stationary → null hypothesis H0H_0
  • ϕ<1  ⟺  γ<0\phi < 1 \iff \gamma < 0 → stationary, mean-reverting → alternative H1H_1

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 γ\gamma 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 γ\gamma. The augmented test soaks up that structure by adding kk lagged differences as control regressors — the ∑j=1kδj Δyt−j\sum_{j=1}^{k} \delta_j\, \Delta y_{t-j} term in the boxed regression above.

These terms whiten the residuals so that the distribution of the test statistic is valid. The lag order kk is chosen to remove residual autocorrelation — commonly by minimising AIC/BIC (statsmodels' autolag="AIC") or a rule of thumb like k=⌊12 (T/100)1/4⌋k = \lfloor 12\,(T/100)^{1/4}\rfloor.

The three test specifications

The deterministic terms α\alpha (drift) and βt\beta t (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:

SpecRegression includesUse when the series…statsmodels regression=
nγyt−1\gamma y_{t-1} onlyfluctuates around zero"n"
cα+γyt−1\alpha + \gamma y_{t-1}fluctuates around a non-zero constant"c" (default)
ctα+βt+γyt−1\alpha + \beta t + \gamma y_{t-1}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 γ^\hat\gamma:

ADF=γ^SE⁡(γ^).\text{ADF} = \frac{\hat\gamma}{\operatorname{SE}(\hat\gamma)}.

Here is the subtlety that catches everyone: under the null this statistic does NOT follow a Student's tt distribution. Because yt−1y_{t-1} is non-stationary under H0H_0, the estimator γ^\hat\gamma 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 −1.96-1.96:

Spec1%5%10%
c (constant)−3.43-3.43−2.86-2.86−2.57-2.57
ct (constant + trend)−3.96-3.96−3.41-3.41−3.12-3.12

(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 −1.8-1.8 does not reject; −5.7-5.7 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 tt-table). Concretely:

p=Pr⁡(DF statistic≤observed ADF  ∣  H0: unit root).p = \Pr\big(\text{DF statistic} \le \text{observed ADF} \;\big|\; H_0:\ \text{unit root}\big).

It answers: if the series truly had a unit root, how often would we see a γ^\hat\gamma 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<0.05  ⇒  reject H0  ⇒  stationary    p≥0.05  ⇒  fail to reject  ⇒  evidence of a unit root  \boxed{\;p < 0.05 \;\Rightarrow\; \text{reject } H_0 \;\Rightarrow\; \textbf{stationary}\;} \qquad \boxed{\;p \ge 0.05 \;\Rightarrow\; \text{fail to reject} \;\Rightarrow\; \textbf{evidence of a unit root}\;}
p-valueInterpretationARIMA action
p<0.05p < 0.05Reject unit root; series is stationaryCurrent dd is enough
p≥0.05p \ge 0.05Cannot reject unit root; likely non-stationaryDifference once more, d←d+1d \leftarrow d+1, re-test

The recipe for choosing dd 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 dd in ARIMA(p,d,q)(p, d, q).

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 ϕ\phi is close to but below 1 (say 0.950.95), a near-unit-root stationary series is easily mistaken for a random walk, so pp stays above 0.050.05 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:

ADFKPSSConclusion
Reject (stationary)Fail to reject (stationary)Stationary ✓: both agree
Fail to rejectRejectNon-stationary (unit root): both agree
Fail to rejectFail to rejectInconclusive: not enough data/power
RejectRejectDifference-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):

Code
ADF statistic: −1.83    p-value: 0.36
5% critical value: −3.41

The statistic −1.83-1.83 is less negative than the −3.41-3.41 critical value, and p=0.36>0.05p = 0.36 > 0.05 → fail to reject → the series has a unit root.

Apply one difference Δyt=yt−yt−1\Delta y_t = y_t - y_{t-1} and re-test (now spec "c", since differencing removed the trend):

Code
ADF statistic: −5.71    p-value: 0.0000
5% critical value: −2.86

Now −5.71-5.71 is far into the left tail and p≈0<0.05p \approx 0 < 0.05 → reject → the differenced series is stationary. One difference removed one unit root, so d=1d = 1. We can now fit the ARMA part of an ARIMA(p,1,q)(p, 1, q) model on Δyt\Delta y_t.

The same workflow in Python

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

Concept neighbourhood

How this concept connects — click any node to jump there, or explore the whole concept map.

RelatedReferenced by
The Augmented Dickey-Fuller TestRandom WalkARIMA Order Selection: Bo…Hypothesis Testing: Null,…ARIMA ModelsTime Series Fundamentals