Mixed-Effects Models
A regression that lets some coefficients be shared across every observation (fixed effects) and lets others vary by group, shrunk partway toward the group average based on how much data that group has (random effects).
Prerequisites: Ordinary Least Squares (OLS), Panel Data and Fixed Effects
Suppose you're estimating how much a stock's return responds to earnings surprises, but you have data across 400 companies in 11 sectors, and you suspect the sensitivity differs by sector. Fit one regression per sector and small sectors with only a handful of names give wild, noisy estimates. Pool everything into one regression and you erase real sector differences — a utility stock and a biotech stock don't react to earnings the same way. A mixed-effects model gives you a middle path: each sector gets its own estimated sensitivity, but that estimate is pulled toward the overall average by an amount that depends on how much data the sector has.
An analogy: grading on a curve, by classroom
Imagine estimating each classroom's average test score across a school district. A classroom of 3 students that happened to score very high shouldn't be trusted as much as a classroom of 200 students scoring the same average — the small classroom's number is more likely to be a fluke. Mixed-effects models formalize exactly this instinct: an estimate built from little data gets pulled ("shrunk") harder toward the overall average, while an estimate built from lots of data is left close to what the data alone says.
The model, one piece at a time
A mixed-effects model splits coefficients into two kinds. Fixed effects are parameters assumed identical across every group — for instance, the overall market-wide sensitivity to earnings surprises. Random effects are group-specific deviations from that fixed effect, treated as random draws from a shared distribution rather than as separate free parameters. For group (a sector) and observation within it:
Here and are the fixed, district-wide intercept and slope; is sector 's own random deviation from that intercept, assumed drawn from a normal distribution with variance ; and is ordinary observation-level noise with variance . In plain English: every observation follows the same overall relationship, plus a sector-specific nudge, plus individual noise — and the model estimates how much sector-to-sector variation there typically is () directly from the data, rather than assuming it away or letting each sector run free.
The key output is the shrinkage factor for each group's estimate, roughly , where is the group's sample size. A group with a lot of data ( large) has this factor close to 1 — its own average dominates. A group with little data has it close to 0 — the model falls back on the overall average.
Worked example 1: shrinking sector intercepts
Suppose the district-wide (fixed) average earnings-surprise sensitivity is . Sector A (utilities) has 200 observations and a raw sector-specific slope estimate of 0.4. Sector B (biotech) has only 5 observations and a raw estimate of 3.0. With estimated variances and , the shrinkage factor for A is , so A's mixed-effects estimate lands near — barely pulled at all. For B, the factor is , so B's estimate lands near — pulled well back from its noisy raw value of 3.0 toward the district average.
Worked example 2: fund manager skill across accounts
A multi-manager platform tracks 50 portfolio managers, some running strategies for 8 years, others for 6 months. A manager with 6 months of a 25% annualized return has a shrinkage factor near 0.1 given typical variance estimates, so their mixed-effects skill estimate sits close to the platform-wide average, not at 25%. A manager with 8 years of a steady 12% return has a shrinkage factor near 0.9, so their estimate stays close to their own track record. This is why allocators use hierarchical shrinkage rather than raw historical returns to rank short-tenured managers — raw returns overstate how much a few good months tell you.
What this means in practice
Mixed-effects models show up wherever a quant has grouped panel data with unequal group sizes: sector-level factor sensitivities, per-trader or per-desk risk models, per-exchange microstructure parameters, or per-country macro betas. They beat running one regression per group (too noisy for small groups) and beat pooling everything (erases real group differences) at the same time, and the shrinkage is derived from the data's own variance structure rather than a subjective choice.
Mixed-effects models estimate group-specific coefficients as a data-driven compromise between "trust this group's own data completely" and "ignore group differences entirely" — the compromise point is set automatically by how much data each group has and how much groups genuinely differ.
A common mistake is treating shrunk (mixed-effects) estimates as if they were the group's true fixed value with no remaining uncertainty — a small group's shrunk estimate is a compromise, not evidence that the group actually behaves close to average. It's also a mistake to run mixed-effects models on groups that aren't exchangeable (e.g., mixing a genuinely different asset class into "sectors") — the model borrows strength across groups by assuming they're drawn from a common distribution, and that assumption fails if one group is structurally different rather than just noisier.
Related concepts
Practice in interviews
Further reading
- Gelman & Hill, Data Analysis Using Regression and Multilevel/Hierarchical Models, ch. 11-12