Basic Prerequisites: Econometrics & Time Series and 01 · From Zero.
1. Intuition & Practical Objective
This is the measurement page: given two candidate assets, (i) test whether they are cointegrated, (ii) extract the spread, and (iii) summarise its mean reversion with one speed parameter and one half-life. The practical objective is a pipeline: regress → test the residual → fit an AR(1) → read off and . Everything downstream (entry/exit thresholds, holding horizon, whether to trade the pair at all) is built on these four numbers.
The key insight is that cointegration is not a property of either series alone but of the combination, and that the same relationship can be written two equivalent ways:
- Static (Engle–Granger): with stationary - the “long-run equilibrium” the spread reverts to.
- Dynamic (Error-Correction Model): the short-run changes of both legs are pulled by the previous period’s disequilibrium . This is the Granger representation theorem: cointegration an error-correction representation exists.
The error-correction picture is what makes pairs trading mechanical: if the spread is above equilibrium, either falls, rises, or both - and the ECM coefficients tell you which leg does the adjusting (the “leader/follower” structure).
2. Mathematical Ground Truth & Derivations
2.1 The Engle–Granger two-step method (Tsay §8.5–8.6)
Step 1 - the cointegrating regression. Estimate by OLS the static long-run relation
and form the residual .
Step 2 - test the residual for a unit root. Run an augmented Dickey–Fuller regression on the residual:
and reject “no cointegration” if the -statistic on is sufficiently negative. Because is estimated (a generated regressor), the null distribution is not the usual Dickey–Fuller distribution; it is more negative. For variables with a constant and no trend, the asymptotic 5% critical value is about (Engle–Granger 1987; MacKinnon 1991), versus for an ordinary ADF. Using the wrong table is a classic error.
2.2 The error-correction form (Granger representation)
If are and cointegrated, then (Tsay Eq. 8.33, in the bivariate pair case)
where . Cointegration requires and to be opposite in sign (at least one adjusts toward equilibrium; Tsay §8.8 Eq. 8.45). The size of is the speed at which leg corrects - the econometric analogue of price discovery / leadership (Hasbrouck Ch 10). If , no error correction and hence no cointegration.
2.3 The Ornstein–Uhlenbeck spread
The continuous-time model of the spread is the Ornstein–Uhlenbeck (OU) process:
It is the continuous-time AR(1): the increment has conditional mean - positive when (spread too low, expect a rise), negative when . The stationary (equilibrium) distribution is Gaussian with
Discretisation (exact). Solving the OU SDE over a step gives
So a 1-lag OLS identifies the persistence directly, but which coefficient depends on which regression you run:
- Level regression : the slope is the AR(1) persistence , so .
- Δ (change) regression with : the slope is , so .
The two are algebraically identical (); for small the Euler approximation holds to first order. The mean level is (level form).
Half-life. The expected time to close half the gap to equilibrium is
(Equivalently, for the discrete AR(1), - the Tsay Ch 2 mean-reversion half-life.) A spread with of a few days is tradable with daily data; one with of a year is not.
Avellaneda–Lee estimation (Appendix). Using the cumulative residual over a 60-day window and the regression :
with the acceptance filter (half-life under ~30 trading days, i.e. ).
3. Computational Implementation - the full pipeline
Stdlib only. We simulate a known OU spread (/day, days) on top of a common random walk, then run Engle–Granger, the ADF test on the residual, and the OU fit - and check that we recover the truth.
All three stages recover the truth: (true ), an ADF far below the threshold (strong rejection of the unit root), and vs the simulated , giving a half-life of vs days.
4. Failure Modes & First-Principles Breakdowns
- Wrong critical values. Testing the estimated residual with ordinary ADF tables over-rejects cointegration (the true CV is , not ). Use Engle–Granger / Phillips–Ouliaris / MacKinnon tables, or Johansen (Ch 6).
- Low power in short windows. The test has weak power against slowly mean-reverting alternatives: a pair with a half-life of 6 months looks like a random walk in a 250-day sample. Cointegration fails to be rejected is not evidence of a tradeable pair.
- Deterministic-specification sensitivity. Whether you include a constant or a trend changes both and the critical values (Tsay §8.6.1 lists five cases). Choosing the spec after seeing the result is data snooping.
- OLS is biased in finite samples and not necessarily the fastest-reverting combination. Engle–Granger OLS minimises the residual variance of one leg; it is super-consistent but can be inefficient. Johansen (Ch 6) or a symmetric (total-least-squares) estimator can recover the true vector better.
- Half-life estimated on the wrong scale or the wrong regression. Mixing the level regression () with the change regression (), or using the Euler shortcut , introduces error at large ; at daily frequency with the difference is negligible, but be consistent about which regression you fit and about (252 vs 365).
5. References
- Tsay, Analysis of Financial Time Series
- Tsay
- Engle, R. F. & Granger, C. W. J., Econometrica 55(2), 1987.
- Avellaneda, M. & Lee, J.-H., Quantitative Finance 10(7), 2010
- Hasbrouck, Empirical Market Microstructure
6. Connected Graph Bridges
- Back: 01 · From Zero · Index Hub
- Forward: 03 · Pairs Selection & Hedge · 04 · Trading Rules & Backtest
- Base: Econometrics & Time Series · Statistics & Inference
- Advanced: 06 · Advanced Extensions (Johansen multivariate test)