Correlated or cointegrated? Spurious regression and the Engle–Granger test
Two stock prices that have both drifted up over five years will look related in a scatter plot, whether or not they have anything to do with each other. Regress one on the other and the t-statistic will usually say the relationship is highly significant. It’s an illusion with a name, spurious regression, and it’s the reason pairs traders test for cointegration instead of correlation.
Two random walks always seem related
Ordinary regression t-statistics assume the errors are stationary noise. With two independent random walks, the error in is itself a random walk: it wanders, and so do x and y. Over any finite sample both series have trends, and least squares finds a slope that lines the trends up. Granger and Newbold (1974) showed that the usual t-test then rejects “no relationship” far too often, and Phillips (1986) proved that the t-statistic doesn’t converge at all; it grows with the sample size.
In 2,000 simulated pairs of independent 500-day random walks, the slope was “significant at 5%” 89.5% of the time, with a median R² of 0.17. The rule of thumb from Granger and Newbold: be suspicious whenever R² is larger than the Durbin–Watson statistic.
Prices x and y (500 days)
Regression residual y − a − bx
With independent random walks, the residual on the right is itself a random walk: it wanders off and doesn’t come back, and the Engle–Granger statistic usually stays above −3.34. Switch to the cointegrated pair: y = 0.8x plus a stationary spread. The residual now hugs zero and the test rejects comfortably. Push φ towards 0.99 and the spread becomes so persistent that 500 days is no longer enough to tell it from a random walk.
Engle–Granger in two steps
Step 1. Regress on (with a constant) by least squares. The slope is the hedge ratio. If the pair is cointegrated, this estimate is super-consistent: it converges at rate 1/T rather than , so the hedge ratio is estimated very precisely.
Step 2. Run an (augmented) Dickey–Fuller regression on the residuals : , and compare the t-statistic of γ with the Engle–Granger critical values: about −3.90 (1%), −3.34 (5%), −3.04 (10%) for two series. These are more negative than ordinary Dickey–Fuller values because step 1 has already chosen β to make the residual look as stationary as possible. In the simulations above, using −3.34 gave a false-positive rate of 5.7%, close to the nominal 5%.
import numpy as np
from statsmodels.tsa.stattools import coint, adfuller
def engle_granger(y, x):
X = np.column_stack([np.ones_like(x), x])
a, b = np.linalg.lstsq(X, y, rcond=None)[0]
resid = y - a - b * x
t_stat = adfuller(resid, regression="n", autolag="AIC")[0] # compare with EG critical values, not these
return b, t_stat, resid
# statsmodels does both steps with the right critical values:
# t, p_value, crit = coint(y, x)If the test passes, the residual is the spread you trade, and its speed of mean reversion is what the OU half-life post estimates.
Error correction and more than two assets
The Granger representation theorem says cointegrated series have an error-correction form: . When the spread is wide, at least one of the prices moves to close it, and α measures how fast. Estimating α also tells you which leg does the adjusting.
With three or more assets there can be several cointegrating combinations, and Engle–Granger (which finds only one, and depends on which variable you put on the left) is replaced by Johansen’s test, a likelihood-based method that estimates the number of cointegrating relations directly.
Where people slip in interviews
- Using correlation of prices to pick pairs. Price correlations between trending series are mostly spurious. Correlation of returns is about short-term co-movement, which is also not the same as cointegration.
- Using the Dickey–Fuller table for residuals. Use Engle–Granger critical values; otherwise you’ll find cointegration too often.
- Regressing differences to “fix” spurious regression. That’s valid for independent walks but throws away the long-run relationship if the series are cointegrated.
- Forgetting that cointegration can break. A merger, a spin-off or a change in business mix can end the relationship. Re-test on rolling windows.
Try these before you open the answer
Warm-upTwo independent random walks, 500 days. You regress one on the other and get t = 6. Is that evidence of a relationship?Show answer
No. In spurious regressions the t-statistic doesn’t have a t distribution; large values are the norm. About 90% of independent pairs give |t| > 1.96 at this length.
Definitionx is a random walk and y = 2x + u, where u is white noise. Are x and y cointegrated? With what vector?Show answer
Yes. Both are I(1), and is stationary. The cointegrating vector is (1, −2).
Critical valuesThe ADF statistic on your Engle–Granger residuals is −3.1. Cointegrated at 5%?Show answer
No. The 5% critical value for two series is about −3.34. (It would pass the ordinary Dickey–Fuller −2.86, which is exactly the trap.)
Half-lifeThe cointegrating residual follows an AR(1) with φ = 0.9 per day. What's its half-life?Show answer
ECMIn Δy_t = −0.1(y_{t−1} − 0.8x_{t−1}) + ε_t, Δx_t = ε'_t, which asset does the adjusting?Show answer
Only y: its error-correction coefficient is −0.1, while x has none and is a pure random walk. When the spread is positive, y tends to fall back towards 0.8x, closing 10% of the gap a day.
The spurious-regression and test-size numbers come from 2,000 simulated pairs. The figure simulates pairs and runs both steps of the test in your browser.