Markets: A Rigorous Course

13A.2 Unit roots and the Dickey–Fuller test

Core about 25 min

Motivation

Every mean-reversion trade rests on one claim: the spread is stationary. The natural test is to fit an AR(1) and check whether the coefficient is below one. The difficulty is that under the null hypothesis of a unit root the usual asymptotics fail. M10 · 10.7.2 quoted the result; here it is derived.

13A.2.1The regression form#

Start from

yt=ρ yt−1+et,et i.i.d. (0,σ2),y0=0.(13A.1)y_t = \rho\, y_{t-1} + e_t, \qquad e_t \text{ i.i.d. } (0,\sigma^2),\quad y_0 = 0. \tag{13A.1}

Subtract yt−1y_{t-1}:

Δyt=γ yt−1+et,γ=ρ−1.(13A.2)\Delta y_t = \gamma\, y_{t-1} + e_t, \qquad \gamma = \rho - 1. \tag{13A.2}

H0:γ=0H_0: \gamma = 0 (unit root; shocks are permanent; no mean reversion). H1:γ<0H_1: \gamma < 0 (stationary; shocks decay at rate ρ\rho per period). The test is one-sided: γ>0\gamma > 0 is an explosive process, not a stationary one. OLS gives

ρ^−1=γ^=∑t=1Tyt−1et∑t=1Tyt−12under H0.(13A.3)\hat\rho - 1 = \hat\gamma = \frac{\sum_{t=1}^T y_{t-1}e_t}{\sum_{t=1}^T y_{t-1}^2}\quad\text{under } H_0. \tag{13A.3}

13A.2.2The limiting distribution#

Proposition 13A.1Dickey–Fuller, no deterministic terms

Under H0H_0,

T(ρ^−1)⇒12(W(1)2−1)∫01W(r)2 dr,τ^≡ρ^−1se⁡(ρ^)⇒12(W(1)2−1)(∫01W(r)2 dr)1/2.(13A.4)T(\hat\rho - 1) \Rightarrow \frac{\tfrac12\left(W(1)^2 - 1\right)}{\int_0^1 W(r)^2\,dr}, \qquad \hat\tau \equiv \frac{\hat\rho-1}{\operatorname{se}(\hat\rho)} \Rightarrow \frac{\tfrac12\left(W(1)^2 - 1\right)}{\left(\int_0^1 W(r)^2\,dr\right)^{1/2}}. \tag{13A.4}
Proof

Under H0H_0, yt=∑s≤tesy_t = \sum_{s\le t} e_s.

Numerator. Square yt=yt−1+ety_t = y_{t-1} + e_t: yt2=yt−12+2yt−1et+et2y_t^2 = y_{t-1}^2 + 2y_{t-1}e_t + e_t^2. Sum from 1 to TT; the y2y^2 terms telescope:

∑t=1Tyt−1et=12(yT2−∑t=1Tet2).\sum_{t=1}^T y_{t-1}e_t = \tfrac12\Big(y_T^2 - \sum_{t=1}^T e_t^2\Big).

Divide by TT. By the CLT yT/T⇒σW(1)y_T/\sqrt T \Rightarrow \sigma W(1), and by the LLN T−1∑et2→σ2T^{-1}\sum e_t^2 \to \sigma^2. So T−1∑yt−1et⇒σ22(W(1)2−1)T^{-1}\sum y_{t-1}e_t \Rightarrow \tfrac{\sigma^2}{2}(W(1)^2 - 1).

Denominator. Define the step function XT(r)=T−1/2y⌊Tr⌋X_T(r) = T^{-1/2}y_{\lfloor Tr\rfloor} on [0,1][0,1]. The functional CLT (Donsker) gives XT⇒σWX_T \Rightarrow \sigma W in D[0,1]D[0,1]. Since XTX_T is constant on [(t−1)/T,t/T)[(t-1)/T, t/T), ∫01XT(r)2dr=T−2∑t=1Tyt−12\int_0^1 X_T(r)^2dr = T^{-2}\sum_{t=1}^T y_{t-1}^2. The map f↦∫01f2f \mapsto \int_0^1 f^2 is continuous, so T−2∑yt−12⇒σ2∫01W2T^{-2}\sum y_{t-1}^2 \Rightarrow \sigma^2\int_0^1 W^2.

Jointly. Both limits are functionals of the same XTX_T (the numerator is 12(XT(1)2−T−1∑et2)\tfrac12(X_T(1)^2 - T^{-1}\sum e_t^2)), so they converge jointly and the continuous mapping theorem applies to the ratio:

T(ρ^−1)=T−1∑yt−1etT−2∑yt−12⇒12(W(1)2−1)∫W2.T(\hat\rho-1) = \frac{T^{-1}\sum y_{t-1}e_t}{T^{-2}\sum y_{t-1}^2} \Rightarrow \frac{\tfrac12(W(1)^2-1)}{\int W^2}.

The tt-ratio. se⁡(ρ^)2=s2/∑yt−12\operatorname{se}(\hat\rho)^2 = s^2/\sum y_{t-1}^2 with s2→σ2s^2 \to \sigma^2, so τ^=T(ρ^−1) (T−2∑yt−12)1/2/s\hat\tau = T(\hat\rho-1)\,\big(T^{-2}\sum y_{t-1}^2\big)^{1/2}/s, which converges to the second expression.∎

Three consequences a trader should know.

  • The rate is TT, not T\sqrt T. ρ^\hat\rho is "superconsistent" under a unit root. The statistic T(ρ^−1)\sqrt T(\hat\rho - 1) collapses to zero, so the usual normal approximation is useless.
  • The distribution is skewed left. P(ρ^<1)→P(W(1)2<1)=P(∣Z∣<1)=0.6827P(\hat\rho < 1) \to P(W(1)^2 < 1) = P(|Z|<1) = 0.6827. Even for a pure random walk, about two thirds of samples show "mean reversion" (ρ^<1\hat\rho<1). (Simulated with T=1,000T = 1{,}000: 0.686.) This is the same downward bias that M10 · 10.7.2 corrected with Kendall's formula.
  • Using −1.645-1.645 over-rejects. The 5% quantile of τ^\hat\tau is about −1.95-1.95 with no constant and −2.86-2.86 with a constant, not −1.645-1.645.

Deterministic terms With a constant in (13A.2) the regressor is effectively demeaned and WW is replaced by the demeaned Brownian motion W~(r)=W(r)−∫01W\tilde W(r) = W(r) - \int_0^1 W (M10 · 10.7.2). With a constant and a linear trend, WW is replaced by the residual of its projection on (1,r)(1, r). The proofs are identical after projecting out the deterministic regressors (Hamilton 1994, 17.4). The distribution changes each time:

Regression 1% 5% 10% Simulated, T=500T=500, 20,000 draws (1%, 5%, 10%)
No constant (n) −2.57 −1.94 −1.62 −2.55, −1.95, −1.62
Constant (c) −3.43 −2.86 −2.57 −3.46, −2.89, −2.57
Constant and trend (ct) −3.96 −3.41 −3.13 −3.96, −3.42, −3.14

The first three columns are MacKinnon's asymptotic values, as used by statsmodels.tsa.stattools.adfuller; the last column is computed by simulate_df_quantiles in m13a_adf.py.

Which case for a spread? A spread has an unknown non-zero mean, so use a constant. The no-constant case is only for series whose mean is zero by construction (the Engle–Granger residual, 13A.5). The trend case answers a different question: "is the spread stationary around a trend?" A trend-stationary spread is not something you can trade by betting on a return to a fixed level.

13A.2.3Augmentation#

Daily spreads rarely follow an AR(1) exactly. If the true model is AR(pp), the residual in (13A.2) is serially correlated and the DF distribution no longer applies. The fix is to add lagged differences.

Proposition 13A.2ADF form

The AR(pp) yt=∑i=1pϕiyt−i+ety_t = \sum_{i=1}^p\phi_i y_{t-i} + e_t can be written

Δyt=γ yt−1+∑j=1p−1δj Δyt−j+et,(13A.5)\Delta y_t = \gamma\,y_{t-1} + \sum_{j=1}^{p-1}\delta_j\,\Delta y_{t-j} + e_t, \tag{13A.5}
γ=∑i=1pϕi−1=−Φ(1),δj=−∑i=j+1pϕi,(13A.6)\gamma = \sum_{i=1}^p\phi_i - 1 = -\Phi(1), \qquad \delta_j = -\sum_{i=j+1}^p \phi_i, \tag{13A.6}

where Φ(z)=1−∑ϕizi\Phi(z) = 1 - \sum\phi_i z^i. The process has a unit root (Φ(1)=0\Phi(1)=0) if and only if γ=0\gamma = 0.

Proof

For i≥2i\ge2, yt−i=yt−1−∑j=1i−1Δyt−jy_{t-i} = y_{t-1} - \sum_{j=1}^{i-1}\Delta y_{t-j} (telescoping). Substitute:

yt=(∑i=1pϕi)yt−1−∑i=2pϕi∑j=1i−1Δyt−j+et.y_t = \Big(\sum_{i=1}^p\phi_i\Big)y_{t-1} - \sum_{i=2}^p\phi_i\sum_{j=1}^{i-1}\Delta y_{t-j} + e_t.

Swap the order of summation over the triangle 1≤j<i≤p1\le j < i \le p: ∑i=2p∑j=1i−1=∑j=1p−1∑i=j+1p\sum_{i=2}^p\sum_{j=1}^{i-1} = \sum_{j=1}^{p-1}\sum_{i=j+1}^p. Subtract yt−1y_{t-1} from both sides. The coefficient of yt−1y_{t-1} is ∑ϕi−1=−Φ(1)\sum\phi_i - 1 = -\Phi(1), and z=1z=1 is a root of Φ\Phi iff this is zero.∎

With deterministic terms, the ADF regression actually run is

Δyt=c+d t+γ yt−1+∑j=1pδj Δyt−j+et,(13A.7)\Delta y_t = c + d\,t + \gamma\,y_{t-1} + \sum_{j=1}^{p}\delta_j\,\Delta y_{t-j} + e_t, \tag{13A.7}

dropping dd or cc as the case requires. Under H0H_0 and with the other roots of Φ\Phi outside the unit circle, Δy\Delta y is a stationary AR(p−1p-1), the coefficients δj\delta_j are asymptotically normal, and the tt-ratio on γ\gamma has the same DF limit as before. Said and Dickey (1984) extend this to ARMA errors by letting pp grow with TT (at rate T1/3T^{1/3} or slower). In practice choose pp by AIC or BIC, or by testing down from a generous maximum; adfuller(autolag="AIC") does the former.

Exercise link m13a_adf.py builds (13A.7) by hand and must match adfuller(maxlag=p, autolag=None) to 10−910^{-9} for all three trend cases and several pp.

13A.2.4Power, and why more data is not always more information#

Unit-root tests have low power against near-unit-root alternatives. The useful way to see it: under an OU alternative sampled every Δ\Delta, ρ=e−κΔ\rho = e^{-\kappa\Delta}, and the information about κ\kappa grows with the span S=TΔS = T\Delta of the data, not with TT. Sampling a five-year spread every minute instead of every day gives many more observations with ρ\rho closer to one and almost no extra power (Shiller and Perron 1985). 13A.7 makes this precise: the relative standard error of κ^\hat\kappa is about 2/(κS)\sqrt{2/(\kappa S)}.

A complementary test reverses the null. KPSS (Kwiatkowski, Phillips, Schmidt and Shin 1992) tests H0H_0: stationary. Reporting both is good practice: "ADF does not reject a unit root and KPSS rejects stationarity" is a much stronger statement than either alone.

Practitioner notes

  • A spread that "passes" ADF at 5% in one window and fails in the next is the normal case, not an anomaly. Low power plus parameter drift guarantees it. 13A.12 shows this for Indian pairs.
  • Run the test on the spread you would actually trade, with the hedge ratio fixed before the test window, or use the Engle–Granger critical values of 13A.5. Estimating β\beta and then applying DF critical values over-rejects.
  • Do not test price levels of a single stock for mean reversion and expect anything but a unit root. The question is always about a combination.

Create a free account

Reading is open to everyone. An account keeps your progress, answers, notes and code drafts, and gives you the study plan, the journals and the simulator. Running code needs an account approved for it.