Marketing Mix Modeling Lab
Estimate what each marketing channel really contributes to sales, including carryover and diminishing returns, and find a better way to split the same budget.
QUICK START: Choose Your Path
OVERVIEW & LEARNING OBJECTIVES
The chief marketing officer walks into the executive meeting: "Search delivers $4.10 in sales for every $1 spent, while TV averages only $2.40. Finance wants to shift our entire TV budget into Search." Should they? No: average ROI flatters saturated channels. If Search is already near its ceiling, the next dollar you put into Search might only earn $0.90, while TV's next dollar earns $1.65. Marketing Mix Modeling (MMM) estimates the true response curves so you can allocate budgets where marginal return ($dY/dX$) is highest.
🎯 What You'll Learn
- Average ROI and marginal ROI are fundamentally different. Budget decisions run on marginal ROI ($dY/dX$), not historical average ROI.
- Ads keep working after they run (Adstock). Ignore carryover and TV looks weak while search takes all the credit.
- Most sales are base sales. In most businesses, 60–80% of sales would happen anyway without paid marketing this quarter.
- Never trust a response curve past what you have tested. Budget optimizers must stay inside the observed historical spend range.
- Triangulation matters. Observational regressions cannot always separate collinear channels; calibrate with experiments.
Step 1 DATA SOURCE & PREPARATION
Choose a realistic marketing mix scenario or upload your own weekly time series with continuous spend columns.
Variable Roles & Controls
🤔 Try this:
- Load Brightwell, set TV carryover to 0, and observe how TV attribution drops.
- Load Tandem Bikes, toggle seasonality off and on, and watch Social credit shift.
- Load Lumen Beauty, check Diagnostics, and observe the collinearity warnings.
Step 2 SHAPE EACH CHANNEL (ADSTOCK & SATURATION)
Adjust carryover decay and saturation points. Sliders recompute model fit live.
Step 3 WHAT DROVE SALES (FIT, DECOMPOSITION & ROI)
Evaluate model fit, decompose total sales into baseline versus media channels, and compare historical average returns with forward-looking marginal returns.
Actual vs. Fitted Sales with Holdout Window
Compares observed weekly sales against the fitted econometric model. The shaded gray area on the right is held out from training to test honest out-of-sample prediction accuracy.
🔍 Reading Guide: Actual vs. Fitted
A good model tracks weekly peaks and troughs without chasing idiosyncratic noise. If holdout MAPE is substantially higher than training MAPE (holdout_gap), the model is overfitted.
Sales Decomposition Over Time
Stacked area visualization separating underlying baseline sales from incremental sales driven by each paid marketing channel.
🔍 Reading Guide: Decomposition
Base sales are what the business would sell with zero marketing (typically 60–80% for mature brands). Marketing channels create the incremental volume stacked on top.
Channel Contribution, Average ROI & Marginal ROI
Historical average ROI divides total attributed sales by total spend. Marginal ROI measures the derivative dY/dX (the revenue returned by the next dollar invested).
| Channel | Weekly Spend | Total Contribution | Marketing Share | Average ROI | Marginal ROI ($dY/dX$) | Half-Life | Verdict |
|---|
Fitted Response Curves (Steady-State Weekly Return)
Shows diminishing returns (Hill shape 1). Red markers denote current average weekly spend. Solid lines represent historically observed spend; dashed lines represent unverified extrapolation.
Carryover Echo (Adstock Decay from $10,000 Flight)
Visualizing geometric decay: how an initial $10,000 marketing flight persists across subsequent weeks according to each channel's retention parameter (λ).
Step 4 MOVE THE MONEY (BUDGET REALLOCATION)
Reallocate the exact same total marketing budget across channels by shifting funds toward channels with higher marginal ROI, strictly bounded by historically observed spend.
| Channel | Current Weekly Spend | Recommended Spend | Change ($) | Current mROI | New mROI | Binding Constraint |
|---|
Current vs. Recommended Weekly Spend
Dumbbell visualization showing current spend (gray circles) versus recommended spend (green diamonds). The optimizer reallocates budget until marginal returns equalize or bounds bind.
5. WHAT THIS MEANS (START HERE)
6. MANAGERIAL & STATISTICAL INTERPRETATION
🔍 Reveal the Truth (Known-Truth Debrief)
Compare estimated parameters against the true data-generating process.
7. MODEL DIAGNOSTICS & CHECKS
8. REPRODUCIBLE PYTHON CODE
Export clean NumPy & Statsmodels code to run this exact model in Python. Next steps point to PyMC-Marketing for Bayesian priors.
EXPLORATORY QUESTIONS
- On Brightwell, Paid Search delivers a historical average ROI of ~$3.80 while TV delivers ~$2.45. Why would shifting budget from Search to TV increase overall sales?
- Set TV carryover (λ) to 0. Why does TV's estimated contribution shrink, and which channel artificially captures the credit?
- On Tandem Bikes, toggle seasonality off and on. Why does Social credit shrink by over 30% when seasonality is controlled?
- On Lumen Beauty, inspect the spend correlation and VIF between Social and Influencer. Why does the model struggle to separate their effects?
- Why does the budget optimizer refuse to recommend spending above a channel's historical observed maximum?