Markets coveredMatch OddsCorrect ScoreOver / UnderFirst HalfSecond Half
Statometrics
Model Library · Bayesian methods and time series

Hierarchical Bayesian Models

Models that let teams, horses or players borrow strength from their group, shrinking noisy individual estimates towards a sensible league-wide average.

Advancedpre-matchevaluation

In one sentence

A hierarchical Bayesian model estimates many related quantities at once, such as each team's home advantage, and lets each one lean on the group average in proportion to how little data it has.

How it works

Picture 24 Championship clubs, each with half a season of home and away results. Estimate each club's home advantage on its own and you get wild numbers, because 20-odd matches is a small sample. Pool everything into one league figure and you lose real differences between grounds.

A hierarchical model does both. It assumes each team's value is drawn from a league-wide distribution, learns the centre and spread of that distribution from all teams together, and then pulls each team's estimate towards the centre. Teams with noisy data get pulled a lot; teams with plenty of clean data barely move.

This "partial pooling" is the principled version of what good form students do by instinct: "that's a big number, but it's only a dozen runs, so I'll knock it back towards normal."

The maths

In the simplest normal-normal version:

θj∼N(μ,τ2),xj∼N(θj,sj2)\theta_j \sim \mathcal{N}(\mu, \tau^2), \qquad x_j \sim \mathcal{N}(\theta_j, s_j^2) θ^j=μ+wj(xj−μ),wj=τ2τ2+sj2\hat{\theta}_j = \mu + w_j (x_j - \mu), \qquad w_j = \frac{\tau^2}{\tau^2 + s_j^2}
  • θⱼ: team j's true home advantage.
  • μ: the league average home advantage.
  • τ: how much true home advantage varies between teams.
  • xⱼ: team j's raw measured home advantage.
  • sⱼ: the standard error of that raw figure (large when the sample is small).
  • wⱼ: the weight given to the team's own data, between 0 and 1.

In plain English: start at the league average and move towards the team's own figure only as far as its sample size justifies.

Worked betting example

You price a home win using a simple Poisson model: neutral scoring rates of 1.30 (home side) and 1.20 (away side), with home advantage split half added to the home rate and half taken off the away rate. Betfair has the home side at 1.80.

  1. League level (illustrative figures). Average home advantage μ = 0.30 goals; spread between teams τ = 0.10.
  2. Team level. This club's raw home advantage is 0.80 goals, with a standard error of 0.25.
  3. Weight. w = 0.10² ÷ (0.10² + 0.25²) = 0.01 ÷ 0.0725 ≈ 0.138.
  4. Shrunk estimate. 0.30 + 0.138 × (0.80 − 0.30) ≈ 0.37 goals.
  5. Raw pricing. Home rate 1.70, away rate 0.80, P(home win) ≈ 58.8%, fair odds ≈ 1.70. That says back at 1.80: £20 stake, 2% commission, expected profit ≈ 0.588 × £16 × 0.98 minus 0.412 × £20 ≈ +£0.98.
  6. Hierarchical pricing. Home rate ≈ 1.48, away rate ≈ 1.02, P(home win) ≈ 48.0%, fair odds ≈ 2.08. Expected profit on the same bet ≈ 0.480 × £16 × 0.98 minus 0.520 × £20 ≈ minus £2.87.

The raw figure invented an edge that the pooled model removes. That is the typical effect: fewer bets, but fewer false ones.

Where it's good

  • Team-specific home advantage, attack and defence ratings early in a season.
  • Jockey, trainer, sire or course-and-distance effects with uneven sample sizes.
  • Player props (shots, cards, aces) where most players have few observations.
  • Lower leagues and minor tennis tours where data are thin.
  • Combining leagues or seasons while allowing each to differ.

Limitations and pitfalls

  • The model is only as good as its grouping. Pooling Premier League and League Two teams in one group will shrink both wrongly.
  • Assuming normal distributions can mislead for rare events and heavy-tailed effects.
  • Fitting full models needs MCMC, which is slower and can fail silently if you do not check diagnostics.
  • Shrinkage cuts both ways: a team with a real structural edge (an unusual pitch, altitude, a long away trip) will be under-rated at first.
  • Priors on τ matter a lot with few groups; with only a handful of teams the spread is poorly estimated.
  • Markets already shrink informally. The gain comes from shrinking more consistently than the crowd, which is a modest edge at best.

How to build it

  • PyMC, Stan (via cmdstanpy) or brms in R fit hierarchical models directly; statsmodels MixedLM gives a quick non-Bayesian version.
  • Data: match-level results with team, venue and date, ideally several seasons.
  • Start with random intercepts only; add random slopes or time trends once the basic model is calibrated.
  • Practical tip: check that out-of-sample log loss improves over both the fully pooled and the no-pooling versions before trusting it.
Learn it step by step
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