Bayesian AB Testing

Matteo Courthoud10 Jan 2023

Problem

A company that runs many A/B tests has a record of how earlier ideas performed, yet each new experiment is read in isolation. Most ideas have effects near zero, so a large estimate in a single test is more likely luck than a breakthrough. A plain regression takes the number at face value and can ship a weak idea.

Example from the article: a simulated search engine tests infinite scrolling on 10.000 visitors. The regression shows +$0.1524 in monthly ad revenue per user, significant at the 1% level. The 1000 past experiments suggest an effect this large is very rare.

Solution in brief

Fit the treatment effect with a Bayesian linear regression and set the prior of the effect from the past experiments' estimates. The shape of the prior matters as much as its mean and spread. A normal prior shrinks every estimate by the same share, while a fat-tailed Student-t prior shrinks small estimates hard and leaves large ones almost intact.

Questions this case answers
  • How to use the effect estimates of many past randomized experiments to correct the estimate of a new one when a single result looks suspiciously large
  • How to use the results of past A/B tests when estimating the effect of a new experiment?
  • How to choose a prior for a treatment effect in a Bayesian A/B test?
  • How to stop a lucky, extreme A/B estimate from being taken at face value?

Tools and methods

  • Bayesian linear regression — outcome regressed on treatment and a pre-experiment covariate, with priors on all parameters
  • Informative prior from past experiments — mean and spread of earlier effect estimates define the prior of the new effect
  • Student-t prior — fat tails express that breakthroughs are rare but possible
  • PyMC — specifies the model and samples the posterior
Continue reading — it's free

Google or a one-time email code. No password.