Markets coveredMatch OddsCorrect ScoreOver / UnderFirst HalfSecond Half
Statometrics
Model Library · Ratings and regression

Mixed and hierarchical models

Regression models that treat teams, players or trainers as members of a group, shrinking small-sample estimates towards the group average.

Advancedpre-matchevaluation

In one sentence

Mixed models give each player, team or trainer their own effect but pull those effects towards the group average, more strongly when data is thin.

How it works

A striker scores six in ten games, but is he really a 0.6-goals-a-game player? Probably not: ten games is a small sample and luck plays a big role. A mixed model answers by treating him as one of many strikers, whose true rates vary around a common average.

The model has fixed effects, which apply to everyone (home advantage, minutes played), and random effects, which vary by group member (each striker's own finishing rate). The random effects are assumed to come from a shared distribution, so extreme estimates from small samples are shrunk back towards the middle.

The more data a player has, the less shrinkage. A player with 200 games is judged mostly on his own record; one with ten is judged mostly on his peers. This partial pooling is one of the most useful ideas in sports modelling.

The maths

yij=β0+β1xij+uj+εij,uj∼N(0,τ2),εij∼N(0,σ2)y_{ij} = \beta_0 + \beta_1 x_{ij} + u_j + \varepsilon_{ij}, \qquad u_j \sim N(0, \tau^2), \quad \varepsilon_{ij} \sim N(0, \sigma^2) θ^j=wjyˉj+(1−wj) μ,wj=njnj+σ2/τ2\hat{\theta}_j = w_j \bar{y}_j + (1 - w_j)\,\mu, \qquad w_j = \frac{n_j}{n_j + \sigma^2/\tau^2}
  • y_ij: outcome i for group member j (for example, goals in a match for player j).
  • β: fixed effects shared by everyone.
  • u_j: member j's own random effect; τ² says how much members truly differ.
  • σ²: match-to-match noise.
  • θ̂_j: the shrunk estimate for member j; ȳ_j: their raw average; μ: the group average.
  • w_j: the weight on their own data, rising with their number of observations n_j.

In words: the estimate is a weighted average of the individual's record and the group average, with the weight set by sample size and how noisy the outcome is.

Worked betting example

A striker has 6 goals in 10 games (illustrative figures). Strikers in this league average 0.30 goals per game. Suppose the fitted ratio σ² ÷ τ² is 15, meaning 15 games' worth of data balances the prior.

  1. Weight on his own record: 10 ÷ (10 + 15) = 0.40.
  2. Raw rate: 0.60 per game. Shrunk rate: 0.40 × 0.60 + 0.60 × 0.30 = 0.42 per game (equivalently (6 + 15 × 0.30) ÷ 25).
  3. Treating goals as Poisson, P(scores) using raw rate = 1 − e^(−0.60) ≈ 45.1% (fair 2.22). Using shrunk rate = 1 − e^(−0.42) ≈ 34.3% (fair 2.92).
  4. Betfair offers 2.60 on him to score. £10 stake at 2% commission: a win pays £16 × 0.98 = £15.68.
  5. Raw-rate EV ≈ 0.451 × £15.68 − 0.549 × £10 ≈ +£1.58. Shrunk-rate EV ≈ 0.343 × £15.68 − 0.657 × £10 ≈ −£1.19.

The raw number says bet; the shrunk number says the market is closer to right. Hot streaks are where shrinkage saves the most money.

Where it's good

  • Player props: scorers, shots, cards, tennis aces, cricket runs.
  • Jockey and trainer effects in racing, where many have few runners.
  • Team ratings across divisions and seasons, especially promoted sides.
  • Venue, referee and ground effects with uneven sample sizes.
  • Any time you would otherwise throw out groups with small samples.

Limitations and pitfalls

  • The normal assumption for random effects can shrink true outliers (a Haaland-type scorer) too hard.
  • Shrinking to the wrong group average (all players rather than strikers) biases everything; choose groups carefully.
  • Random effects assume members are exchangeable; if selection is not random (only good players get minutes), estimates mislead.
  • Fitting can fail to converge with complex random-effect structures and little data.
  • Skill changes over time, so a static random effect lags form and ageing unless you add time structure.

How to build it

  • Python: statsmodels MixedLM, or bambi and PyMC for Bayesian versions; R: lme4 and glmmTMB, or brms.
  • Data: repeated observations per group member with a clear group label (player, trainer, venue).
  • Use a Poisson or binomial mixed model for counts and yes/no outcomes, not the normal version.
  • Tip: always compare raw and shrunk estimates for players you plan to bet on; large gaps deserve a closer look.
18+ only. Educational content, not financial or betting advice. Past results do not guarantee future returns. If gambling stops being fun, get free, confidential help at BeGambleAware.org.
Members