Skip to content
Module 06 of 1165 min readAdvanced

Unit roots, ARIMA, and cointegration

Dickey-Fuller and KPSS tests, differencing, Engle-Granger and Johansen cointegration — the algebra behind pairs trading.

55%

Listen along

Read “Unit roots, ARIMA, and cointegration” aloud

Plays in your browser using on-device text-to-speech — nothing leaves the page.

Unit-root testing is the gateway: does the series need differencing or not? Cointegration is its multivariate sibling: are two non-stationary series tied together by a stationary spread? These two questions, properly answered, govern most time-series pre-processing in finance — and provide the algebraic foundation of pairs trading.

Unit roots — what they are

A unit root means the characteristic polynomial has a root at 1 (z = 1 in the lag-polynomial). The classic example: random walk X_t = X_{t-1} + ε_t. The AR polynomial 1 - z has root z = 1.

  • Series with a unit root are non-stationary; their variance grows over time.
  • Linear regressions of one unit-root series on another produce spurious regressions — t-stats apparently strong even when the true relationship is none (Granger-Newbold 1974).
  • First-differencing removes one unit root. Most economic series need d = 1 or d = 2 differences to become stationary.

Augmented Dickey-Fuller (ADF) test

math
ΔX_t = α + γ X_{t-1} + Σ φ_i ΔX_{t-i} + ε_t
H₀: γ = 0 (unit root)
H₁: γ < 0 (stationary)

The lagged differences absorb short-term dynamics. Critical values are NOT standard t-distribution values; they're the Dickey-Fuller distribution (more negative — about -2.86 at 5% for the constant-only version).

KPSS test

Complementary to ADF: null is stationarity, alternative is unit root. Disagreement between ADF and KPSS suggests fractional integration or near-unit-root behaviour. Best practice: report both.

Order of integration

X_t is integrated of order d, written I(d), if d differences produce a stationary process. Stationary series: I(0). Random walks: I(1). Returns: typically I(0). Prices: typically I(1). Inflation rates: typically I(1) (though debated). The decision determines whether to model in levels, differences, or cointegrating combinations.

Cointegration — the central idea

Two I(1) series X_t and Y_t are cointegrated if there exists a non-zero β such that Y_t - βX_t is I(0). The two series wander individually but their linear combination doesn't — they share a common stochastic trend.

Pairs trading lives here

Suppose Safaricom and the NSE-20 index are both I(1) and cointegrated with β = 1.5. The spread Y_t - 1.5 X_t is stationary — it wanders around a constant mean and reverts. When it's far above its mean, sell the spread (short Y, long β·X); when far below, buy. The cointegration test (Engle-Granger or Johansen) is the licence to do this.

Engle-Granger procedure

  1. Verify both X_t and Y_t are I(1) (ADF on levels: cannot reject unit root).
  2. Regress Y_t on X_t by OLS: Y_t = α + β X_t + u_t.
  3. ADF on residuals û_t. If residuals are stationary (reject DF unit root), conclude X and Y are cointegrated.
  4. Critical values are different from standard ADF — use Engle-Granger tables.

Johansen procedure

Multivariate cointegration: in a system of n I(1) series, you can have up to n - 1 cointegrating relationships. Johansen's trace and maximum-eigenvalue tests use a VECM (vector error-correction model). More powerful than Engle-Granger in higher dimensions; the standard for multi-asset cointegration analysis.

Error correction representation

When X and Y are cointegrated, the dynamics satisfy a VECM:

math
ΔY_t = α_Y (Y_{t-1} - β X_{t-1}) + Σ Γ_i Δ[Y, X]_{t-i} + ε_t
ΔX_t = α_X (Y_{t-1} - β X_{t-1}) + Σ Γ_i Δ[Y, X]_{t-i} + ε_t

α_Y < 0 means Y adjusts down when the spread is positive (Y is too high relative to βX). The α's are speed-of-adjustment parameters; faster adjustment means tighter mean-reversion in the spread.

Half-life

If the spread follows AR(1) with coefficient ρ, the half-life of a deviation is log(0.5) / log(ρ). A half-life of 5 days is profitable for high-frequency pairs trading; a half-life of 6 months requires very patient capital.

Exercise

You suspect Safaricom (SAF) and KCB are cointegrated. (1) Run ADF on each — both have p-values 0.45 (cannot reject I(1)). Good. (2) Regress SAF on KCB: SAF_t = 5.2 + 0.8 KCB_t + û_t. ADF on residuals gives test stat -3.7; Engle-Granger 5% critical value is -3.34. (3) The residual AR(1) coefficient is 0.92. Compute the half-life. (4) Comment on tradability.

Loading progress…
LeadAfrikPublic Economics Hub