Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

name: mmm-workflow
description: Media-mix workflow with the built-in media-mix regressions — search adstock decays with an lhs sweep, bind the winner as the Hill fit, score contributions and reallocate budget with compose optimize, all in one compose call; or fit the Bayesian model for intervals. The one-call recipe, decay intervals, lift tests as likelihood or prior, what to trust.
kind: design
type: guide
applies_to: compose
requires: [REG_MMM_HILL, WIN_DISTRIBUTED_LAG, WIN_LAG, ATTR_FORMULA, capability:for_each, capability:compose_sweep_sampling, capability:compose_sweep_bind, capability:compose_optimize]
covers: [Bayesian media mix, lift test prior, lift test likelihood, media mix, MMM, adstock decay, Hill curve, marginal ROI, budget reallocation, one-call recipe, sweep_axis, response]

Media-mix workflow

Goal: per-channel decay, response curve and a budget split that equalises marginal ROI. The decay is nonlinear in the adstock, so it is searched; the curves are fitted jointly by REG_MMM_HILL. One compose call does it all: no template, no second call, no label parsing.

The one call

  • sweep: lhs (compose-sweep-sampling), one axis per channel decay with a range (TV-like [0.3, 0.8], digital [0, 0.4]; keep max below 1), samples in the thousands, rank {by: "regressions.mmm.holdout.rmse", order: "asc"}. Each slot: one WIN_DISTRIBUTED_LAG per channel (kernel: geometric, decay: {"$var": "tv"}, normalize: false), then one REG_MMM_HILL named mmm with params.channels and a holdout on the last weeks. Use enough samples for the channel count and check the best slots agree on the decays. MaxComposeSlots counts the samples plus the explicit slots: raise Options.Limits.MaxComposeSlots (CLI --limit max_compose_slots=2001).
  • fits: [{"name": "mmm", "from_sweep": {"regression": "mmm"}}] refits the winning slot’s regression, its holdout kept (compose-sweep-bind).
  • requests: one contribution slot. A window’s decay is a literal, so rebuild each adstock at the winner’s decay: one WIN_LAG item (ordered by week) fanned out with for_each over channel × lag 1..max_lag, label {{ch}}_l{{lag}} (params: {offset: {"$var": "lag"}, default: 0}, item-fan-out), then an ATTR_FORMULA per channel labelled tv_ad, tv + d * (tv_l1 + d * (tv_l2 + … + d * tv_l13)) with d written as sweep_axis("mmm", "tv"), then coef("mmm", "tv_ad") * hill(tv_ad, coef("mmm", "k:tv_ad"), coef("mmm", "s:tv_ad")).
  • optimize: maximise the summed steady-state curves, response("mmm", "tv_ad", tv) + …, under sum(spend) = budget (compose-optimize). Current spend, bounds and the budget are your own figures in params.

Run order: the sweep slots, the rank, the bound fit, then optimize and the contribution slot. The winning decays are ranking[0].axes, typed numbers. At the optimum every free channel’s marginal equals the budget multiplier.

Steady-state response

response(fit, channel, spend) = beta · hill(m · spend, k, s): beta, k, s the fit’s <ch>, k:<ch>, s:<ch> coefficients (Bayes: posterior means on its own curve; a geo panel’s population, or a 4th geo argument’s own, mmm-bayes-model), m the sum of the channel’s adstock kernel weights over lags 0..max_lag — the level a constant spend of 1 settles to (geometric: (1 - d^(max_lag+1)) / (1 - d); normalised: 1). It reads the fit’s own adstock record, never a default: a Hill channel that is one WIN_DISTRIBUTED_LAG label (sweep winner included) or fitted by params.adstock, every Bayes channel, or an inline model’s declared adstock. Any other channel is PULSE_MODEL_TERM_UNKNOWN adstock_unknown (details.channel; predict too when the fit and channel are literals, except on a from_sweep fit, judged at run). Works in optimize objectives, constraints and bounds and in formulas. hill() is Hill only: read other curves through response().

Contribution by quarter

Add groups (GROUP_DATE on a date field, params.component: "quarter") and one AGG_SUM per channel over its contribution label to the contribution slot. An aggregation reading a post-window label runs the slot windows-first (windows-first): the lags, adstock and contribution are computed per week, then summed per quarter, and the rows are quarters. Weight the aggregations, never the request: a window has no weighted form.

Bayesian route vs LM/sweep route

  • LM/sweep (above): fast (seconds per fit), scores holdout, saves and feeds compose optimize. Decay is a sweep axis (betas, k, s decay-conditional), or params.adstock fits it, with SE (op-reg-mmm-hill).
  • REG_MMM_BAYES (op-reg-mmm-bayes): one fit adstocks raw spend and returns ROI, mROI and contribution intervals that include decay uncertainty; about 35 s per default fit. With return_draws it saves, scores and feeds optimize over its draws (posterior, mmm-bayes-posterior). Needs order.field as contiguous integers (a date is time_gap).
  • Pick the sweep to allocate budget, Bayes to say how sure you are. Reading an interval: an always-on channel is the hardest to identify and gets a wide interval, so read its width, not its centre. Check diagnostics first (Strict fails on a sampler warning).

Lift tests: likelihood or prior

  • Likelihood (preferred): params.lift_tests [{channel, start, end, spend_delta, lift, se}] scores the model’s change in the outcome over the test’s periods (no carry-over past end) against the measured lift, in outcome units (mmm-bayes-model): the experiment’s own estimand.
  • Prior: priors.<channel>.roi lognormal, mu = ln(ROI), sigma ≈ ln(upper/lower)/3.3 (90% interval). Estimands must match: the model’s ROI is the whole fitted period against zero spend, a short geo test is not, so widen sigma; data can overrule it.
  • One experiment, one route: a channel with both warns PULSE_MMM_LIFT_PRIOR_OVERLAP (evidence counted twice).

Intervals and trust

  • Decay: a sweep has no SE; report the near-best ranks’ decays (ranking[i].axes), or fit params.adstock. For beta intervals, resample an authored fit at the winning decays: on the sweep regression it would run in every slot.
  • Curves: an underfunded channel’s k and s are weakly identified; trust its ROI, not its k.
  • Check starts_agreeing on the optimize result.
  • Known truth (a synthetic cohort): declare it as an inline models entry (numbers may be params.<name>) and run the same optimize objective over it beside the fit (compose-optimize).

See

op-reg-mmm-hill · op-reg-mmm-bayes · mmm-bayes-model · compose-sweep-sampling · compose-sweep-bind · compose-optimize · item-fan-out · regression-model-options · windows-first