Skip to content

Marketing Mix Modeling

Marketing Mix Modeling (MMM) decomposes an aggregate outcome into baseline, control, and media-response components over time.

The repository treats MMM as a causal time-series problem with strong identification requirements, not merely as a forecasting regression.

Weekly multi-channel DGP

The controlled simulation contains five years of weekly data for:

  • search;
  • social;
  • TV;
  • promotions;
  • an external demand driver;
  • trend and annual seasonality.

Media spend varies broadly over time. This is deliberate: without enough independent variation across spend levels, adstock and saturation parameters are weakly identified.

For channel j, spend is transformed in two stages.

Geometric adstock

Carry-over follows

[ A_{jt} = S_{jt} + \lambda_j A_{j,t-1}, \qquad 0 \leq \lambda_j < 1. ]

A larger lambda means a slower decay of past spend.

The implementation uses geometric_adstock and estimates one decay parameter per channel.

Saturation

Diminishing returns use a one-parameter Hill curve:

[ R_{jt} = \frac{A_{jt}}{A_{jt}+h_j}, ]

where h_j is the adstock level at which the response reaches one half.

Channel contribution is

[ C_{jt} = \beta_j R_{jt}. ]

The DGP stores exact adstock, saturation, and contribution trajectories.

Frequentist MMM

fit_marketing_mix profiles the nonlinear response parameters.

For any candidate set of decay and half-saturation parameters, the transformed media variables are constructed and the linear regression coefficients are solved by least squares.

The nonlinear optimizer therefore searches only over the media-transformation parameters.

The final regression contains:

  • intercept;
  • trend;
  • sine and cosine seasonality;
  • promotion;
  • external demand control;
  • one saturated adstock regressor per channel.

Robust HC1 covariance is reported for the regression coefficients.

Parameter identifiability

Decay, saturation, and coefficient scale can trade off against one another if spend occupies only a narrow range.

The benchmark DGP uses broad, partly independent lognormal spend variation and low observation noise. Under that controlled design, decay and half-saturation parameters can be recovered within useful tolerances.

This is a designed identifiability experiment, not a claim that all real MMM datasets identify nonlinear media response cleanly.

channel_recovery_table compares fitted parameters and aggregate channel contributions directly with known truth.

Channel contribution and ROI

For a fitted channel,

[ \widehat C_{jt} = \widehat\beta_j\widehat R_{jt}. ]

Total channel contribution is the time sum of this quantity.

The repository defines a simple outcome-per-spend ROI:

[ ROI_j = \frac{\sum_t \widehat C_{jt}} {\sum_t S_{jt}}. ]

If the outcome is revenue, this has a direct revenue interpretation. If the outcome is another quantity, the unit of ROI changes accordingly.

Response curves and marginal return

channel_response_curve evaluates the steady-state response to a constant weekly spend level.

At steady state,

[ A(S)=\frac{S}{1-\lambda}. ]

The function reports:

  • expected steady-state contribution;
  • average ROI;
  • marginal contribution per additional unit of spend.

The marginal return decreases as spend rises because the Hill response saturates.

Budget counterfactuals

evaluate_budget_scenario scales one or more observed channel spend paths and recomputes the full adstock and saturation trajectory.

This preserves carry-over dynamics when evaluating a new budget.

optimize_budget_allocation chooses channel multipliers subject to a fixed total spend constraint.

The current optimizer scales each channel's observed weekly spend pattern rather than designing a completely new week-by-week schedule. That makes the counterfactual interpretable while keeping the optimization problem compact.

Frequentist uncertainty

frequentist_channel_uncertainty samples the estimated regression coefficient vector from its robust multivariate-normal approximation.

Each draw is propagated into:

  • total channel contribution;
  • channel ROI.

The nonlinear transformation parameters are held fixed at their point estimates. The resulting intervals are therefore conditional intervals, not a full accounting of nonlinear-parameter uncertainty.

Conditional Bayesian MMM

fit_bayesian_mmm places a weak conjugate normal-inverse-gamma prior on the regression layer while holding the fitted adstock and saturation parameters fixed.

Posterior coefficient draws are propagated into contribution and ROI distributions.

This gives the repository a transparent frequentist-versus-Bayesian comparison without hiding the likelihood behind a specialised MMM package.

It is intentionally a conditional Bayesian formulation. Issue #17 expands the repository into broader Bayesian and hierarchical causal modelling, where nonlinear and hierarchical uncertainty can be treated more fully.

Causal interpretation

Observational MMM is not automatically causal.

A causal interpretation requires, among other things, that after conditioning on the modelled controls, media spend does not still share unmeasured causes with the outcome.

Examples of dangerous omitted variables include:

  • demand shocks that simultaneously trigger more advertising;
  • competitor activity;
  • pricing changes;
  • distribution constraints;
  • product launches;
  • targeting rules that react to expected future sales.

Adstock, saturation, Bayesian inference, and excellent predictive fit do not remove this confounding.

The methodology contract therefore includes media-spend exogeneity and a stable data-generating process as explicit assumptions.