name: mmm-bayes-posterior
description: REG_MMM_BAYES raw posterior draws — params.return_draws and params.draws_thin, the outputs.draws shape (names, draws per chain, per-draw ROI), how the draws relate to the reported summaries, null draws, the Limits.MaxMMMDrawValues cap and response shaping — saving and scoring a fit over its draws (pre-adstocked or carried inputs, credible bounds, unseen geos, the two holdouts), a budget optimised over the draws (optimize posterior), and choosing the sampler (nuts or static hmc, path_length, step_size).
kind: design
type: guide
applies_to: process, compose, predict
requires: [REG_MMM_BAYES]
covers: [posterior draws, return_draws, draws_thin, thinning, per-draw ROI, draws limit, save, scoring, pre-adstocked inputs, credible bound, unseen geo, engine holdout, optimize posterior, allocation interval, sampler, hmc, path_length, step_size]
Bayesian MMM: raw posterior draws
REG_MMM_BAYES (op-reg-mmm-bayes) summarises its posterior in outputs. Ask for the draws when a summary is not the question: a probability (P(ROI > 1)), a contrast between channels, a custom interval.
Asking for draws
params.return_draws: true adds outputs.draws; params.draws_thin: k (an integer 1–20000, default 1) keeps every k-th retained draw of each chain (draw 0, k, 2k, …), so a chain returns ⌈draws / k⌉. draws_thin without return_draws is PROCESSING_CONFIG reason draws_thin_without_return_draws. Neither key moves the derived seed, so the posterior is unchanged.
Shape
{"names": ["(intercept)", "tv", "price", "decay:tv", "k:tv", "s:tv", "sigma"],
"draws": [[[...], ...], ...],
"roi": {"tv": [[...], ...]},
"thin": 1, "credible_level": 0.9}
credible_levelis the fit’s (a scoring bound reads it).draws[chain][i][d]: coefficientnames[i]at kept drawd, on the constrained scale in original units — the valuesoutputs.paramssummarises.roi[<entry>][chain][d]: eachoutputs.roientry’s draw; on a geo panel also<ch>[<geo>], andnamesis the panel’s table (tv[NE],tau:tv, …;mmm-bayes-model).- Pool chains in chain order then draw order: with
draws_thin1 the pooled draws summarised reproduceoutputs.roiandoutputs.paramsexactly. - A non-finite draw is
nullon the wire; decoded into a float slot it reads back as NaN, never 0.
Size limit
The payload is chains × kept draws × (coefficients + roi entries) values, capped by Limits.MaxMMMDrawValues (max_mmm_draw_values in the manifest limits). Over it the fit is refused with PULSE_LIMIT_EXCEEDED before any sampling, never truncated: raise draws_thin or the limit. Predict reports the same figure: certain (and the same refusal) on one market, possible on a geo panel, whose count grows with the geos it reads.
Response shaping
outputs is kept by the standard return preset (the MCP default), so the draws arrive exactly when return_draws asked for them. exclude: ["regressions[*].outputs.draws"] drops them from the wire alone.
Saving and scoring
A fit scores over its draws, so save, the engine holdout and scoring it (op-attr-reg-predict, a params.fit slot) need return_draws: true; without it they are refused draws_required (PROCESSING_CONFIG; scoring PULSE_MODEL_SCORE_INVALID), in predict too. The file keeps the thinned draws even when exclude: ["regressions[*].outputs.draws"] drops them from the wire.
- A score carries the fit’s adstock into raw spend (
params.order,regression-order). Undercarryover: falseinputs are pre-adstocked: build each channel withWIN_DISTRIBUTED_LAGfrom the file’sadstock.<ch>record (posterior-mean params,normalize: false,fixed_at: "posterior_mean"). Either way the decay’s uncertainty is not in the score. - The score is the mean over the draws of α + Σγ·z + Σβ·curve(x). Whole-model
bound: "lower"/"upper"(noterms) is the credible bound of that mean atcredible_level: an interval for μ, not a predictive interval (no σ). - A geo panel’s scoring frame needs the
geofield; each row uses its geo’s intercept, β and curve. A geo the fit lacks scores from the population (each channel’s μ β and curve, the mean geo intercept) and warnsPULSE_MMM_GEO_UNSEEN(geos,rows,fit_geos). - Two holdouts:
params.holdout_fromadstocks every period at each draw’s decay, the fit seeing those before it. The engineholdoutfits the train rows and carries their adstock (posterior-mean kernel) into the held-out rows;carryover: falsescores their columns as given.
Optimising over the draws
A Compose optimize block’s posterior: {objective, q, draws} (compose-optimize) evaluates its objective once per draw and optimises their mean (default) or quantile q (type 7, as the credible intervals; maximise a low q for a cautious plan); each constraint holds on its mean over the draws, while bounds and starts read the posterior means. draws: N takes a seeded subsample (the block’s rng_seed); 0 is every draw. Per draw, response() reads that draw’s β, curve and decay; with a geo argument that geo’s own draws, without one the population’s.
- The objective and constraints read exactly one fit by literal name: a Compose fit with
return_draws: true, or amodelsfile that kept its draws. ElsePULSE_OPTIMIZE_SPEC_INVALIDreasonposterior_fit_missing,posterior_fits_multiple,posterior_fit_not_bayesordraws_required, in predict too. - Each variable adds
interval: thecredible_levelrange of its optimum when the block is re-solved on each draw alone (one start, at the reported optimum).posteriorechoesfit,draws,draws_availableanddraws_resolved(re-solves that converged; the interval is over those). - Cost grows with the draws: subsample a long run.
Choosing the sampler
NUTS (params.sampler nuts, the default) tunes each trajectory itself; keep it unless you need a fixed cost per draw. hmc is static HMC: every transition runs ⌈path_length / step size⌉ leapfrog steps, so path_length is required (refused under nuts, as is step_size).
- Start at
path_lengthπ/2 (1.5708): on the adapted unit-scale metric a quarter period moves a draw to a nearly independent point. Stan’s 2π brings it back near its start; much shorter paths random-walk. Readess_bulk/ess_tailand lengthen the path when they are low. - Omit
step_sizeto adapt it towardstarget_accept; a fixedstep_sizeturns adaptation off (target_acceptbeside it is refused). Divergences: lower it. Adapting, a warmup path stops at 1023 steps (NUTS’s cap); draws run the full path. - No tree:
diagnosticshas notreedepth_saturated/max_tree_depthand that warning never fires.
See
op-reg-mmm-bayes · mmm-bayes-model · response-shaping · compose-optimize