Bayesian Hierarchical Marketing Mix Modeling in PyMC

Robert Kübler25 Jul 2022

Problem

A marketing team that advertises in several countries wants to know what each channel (TV, radio, banners) contributed to sales. A single model for all countries ignores that markets differ and underfits. One model per country multiplies the models to maintain and overfits in markets with few observations. Budgets then rest on estimates that are either too coarse or too noisy.

Example from the article: in a synthetic dataset, Switzerland has only 20 observations, so its stand-alone model gives very wide posteriors; the 94% highest density interval (HDI) of the carryover parameters spans nearly the whole range from 0 to 1. Germany and Austria have more data and fit well.

Solution in brief

Fit one Bayesian marketing mix model for all countries, where each country gets its own channel parameters. These parameters are drawn from shared distributions whose parameters are learned from the data. Data-poor countries borrow strength from similar countries, and data-rich countries can still deviate.

Questions this case answers
  • How to estimate the effect of aggregate-level spend on an outcome for several related segments when some segments have too few observations for a separate model and one pooled model is too coarse
  • How to estimate advertising channel effects in a market that has only a few weeks of data?
  • How to build marketing mix models for several related countries without fitting one model per country?
  • How to keep carryover and saturation estimates stable when some markets have little history?

Tools and methods

  • Hierarchical Bayesian marketing mix model — country-level channel parameters drawn from shared hyperpriors
  • Adstock (carryover) and exponential saturation — lagged effect of spend and diminishing returns per channel
  • PyMC — model specification and MCMC sampling
Continue reading — it's free

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