Marketing Media Mix Models with Python & PyMC: a Case Study [PyCon DE & PyData Berlin 2024]

Learn how to build marketing mix models using Python & PyMC. Explore Bayesian regression, ad stock transformations, and practical tips for analyzing marketing channel impact.

Key takeaways
  • PyMC enables building and solving marketing mix models with Bayesian regression, providing uncertainty estimates for parameters

  • Marketing contribution analysis is more practical than attribution tracking - focus on aggregate channel impact rather than individual customer journeys

  • Ad stock transformation helps model the accumulated/persistent effects of marketing investments over time

  • Cross-correlation and Spearman correlation are useful for analyzing relationships between marketing spend and sales KPIs, especially for non-linear patterns

  • Setting appropriate priors is crucial - use domain knowledge to constrain parameters (e.g., half-normal distribution for ensuring positive returns)

  • Model validation should be done out-of-sample with test sets to avoid overfitting

  • Baseline effects (brand strength, seasonality) need to be separated from marketing channel contributions

  • Linear regression alone is insufficient due to:

    • High error with high promotion levels
    • Potential negative baselines
    • Coefficient instability
  • Channel timing is critical - investments should align with when customers are most likely to convert

  • Privacy changes (cookie deprecation) will make attribution tracking increasingly difficult, reinforcing the need for contribution-based modeling approaches