Cointegration

Two price series can each wander without a mean and still be tethered to one another, so that a particular combination of them does revert. That is cointegration, and it is a stronger and more durable relationship than correlation. FolioLab tests every pair in your universe for it, over two windows, and reports which pairs hold up in both.

Correlation Is Not the Same Thing

Correlation is computed on returns and describes co-movement day by day. Two stocks can be highly correlated for a year while their prices drift steadily apart the whole time, because moving together in the short run says nothing about staying together in the long run. That is exactly the failure mode of a hedge built on correlation alone: the daily offset works, the cumulative gap does not close.

Cointegration is computed on prices and describes exactly the property correlation misses. Two series are cointegrated when both individually carry a unit root, yet some linear combination of them is stationary. Neither price has a mean to return to; the spread between them does. Shocks to the pair are transient rather than permanent, and the gap has a level it is pulled back to.

The relationship also runs the other way in a useful sense: cointegrated series can look weakly correlated over short horizons while remaining reliably tied over long ones. It is genuinely a different question, and answering it takes a different test.

The Engle-Granger Test

Two steps: the hedge ratio and the spread

Engle and Granger (1987) reduce cointegration testing to a stationarity test on a residual. First, regress one price series on the other:

The slope is the hedge ratio: the number of units of B that offsets one unit of A. The residual is the spread, the quantity whose behaviour the whole test is about.

Second, test that spread for a unit root, exactly as described on the stationarity page:

A stationary spread () means the two prices cannot drift apart indefinitely, which is cointegration. A spread with a unit root means the regression found a relationship that holds only in-sample, the classic spurious regression that Granger and Newbold warned about.

Why the critical values shift again

The residual being tested is not observed data, it is the output of a regression that was fitted to make it as small as possible. That fitting biases the test toward finding stationarity, so the ADF critical values are not valid here. Engle-Granger uses its own more demanding table, and FolioLab reports the 1%, 5% and 10% critical values alongside every pair's statistic.

The error-correction representation

The deeper content of the Engle-Granger paper is the representation theorem: cointegration is equivalent to the existence of an error-correction model.

with . Yesterday's deviation from the long-run relationship predicts today's move back toward it. This is why cointegration is interesting beyond diagnostics: it is a statement that the spread carries information about future direction, which correlation never does.

What FolioLab Runs

Every pair of assets in the universe is tested on price levels, with a constant term and AIC lag selection, over a trailing 1-year window (252 observations) and, when enough history exists, again over a trailing 2-year window (504 observations). Pairs with fewer than 50 overlapping observations are skipped rather than tested.

Both regression directions are run, and the stronger one is kept. Engle-Granger is not symmetric: regressing A on B and regressing B on A produce different residuals and different statistics, and there is no principled reason to prefer either ordering in advance. FolioLab runs both and selects by the lower p-value, breaking ties on the statistic and then on ticker order so the choice is deterministic and reproducible. The direction that won is reported with the pair, because the hedge ratio only makes sense once you know which series is the dependent one.

For pairs that test as cointegrated at the 5% level, the payload additionally carries the regression intercept, the hedge ratio, and the half-life of mean reversion estimated on the fitted spread.

The stability flag is the part to trust. When both windows ran, a pair is marked stable only if it tested as cointegrated in the 1-year window and the 2-year window. A pair that appears in one window alone is far more likely to be a coincidence of the sample than a durable relationship, and the flag exists to keep that distinction visible rather than buried.

How To Read The Results

The card shows a heatmap of pairwise p-values plus a table of the cointegrated pairs, and a headline count with the share of tested pairs that passed.

PatternWhat it usually means
Few pairs, all stable across both windowsGenuine long-run linkages, most often same-sector names or a stock and an index it dominates. The most informative outcome.
Many pairs cointegrated at 1Y, few stableUsually a shared regime inside the shorter window rather than structural linkage. Weight the 2-year result.
A very high cointegrated shareRead it as a warning about the universe, not a discovery: near-duplicate holdings, or a market-wide trend all names are riding.
No pairs at allEntirely normal for a diversified cross-sector portfolio, and mildly reassuring about its diversification.

Cointegrated pairs inside a portfolio are worth knowing about even if you never trade the spread. They are holdings whose long-run behaviour is tied together, so the diversification the optimizer thinks it bought from them is smaller than the correlation matrix suggests.

Limitations

  • Multiple testing, at scale. A 20-asset universe generates 190 pairs. At the 5% level roughly nine will pass by chance. This is precisely why the two-window stability flag exists, and why a raw pair count is close to meaningless on a large universe.
  • Pairwise only. Engle-Granger tests one relationship between two series. A universe can hold multiple cointegrating vectors among three or more assets that no pairwise test will find; that needs the Johansen procedure, which FolioLab does not run.
  • Relationships break. Cointegration is estimated on a window and says nothing about whether the linkage survives a merger, a regulatory change, or a shift in capital structure. The stability flag mitigates this; it does not solve it.
  • The hedge ratio is a static OLS slope. It is fitted once over the window, with no allowance for the ratio itself drifting. A time-varying estimate needs a Kalman filter.
  • Low power on short windows. The 1-year test in particular has limited ability to detect slow mean reversion. A half-life comparable to the window length will usually go undetected.

References

  1. Engle, R. F., & Granger, C. W. J. (1987). "Co-integration and Error Correction: Representation, Estimation, and Testing." Econometrica, 55(2), 251-276. doi:10.2307/1913236.
  2. Phillips, P. C. B., & Ouliaris, S. (1990). "Asymptotic Properties of Residual Based Tests for Cointegration." Econometrica, 58(1), 165-193. doi:10.2307/2938339.
  3. MacKinnon, J. G. (1996). "Numerical Distribution Functions for Unit Root and Cointegration Tests." Journal of Applied Econometrics, 11(6), 601-618. doi:10.1002/(SICI)1099-1255(199611)11:6<601::AID-JAE417>3.0.CO;2-T.

Not investment advice. Past performance is not indicative of future results.