Chapter 08 of 10
Derived quantities
Average ROI, marginal ROI and contribution — each computed per draw, because the mean of a ratio is not the ratio of the means.
ROI is a ratio and the response surface is nonlinear, so the mean of a ratio is not the ratio of the means and the curve through the average is not the average of the curves. A 90% interval on ROI has to come from the ROI of each individual draw.
Counterfactuals reuse the scalers fitted on the observed data. Refitting the median divisor on counterfactual spend would redefine the units the ROI prior lives in — and for a zeroed channel it is undefined.
Contribution, by counterfactual
Each channel’s incremental outcome is its transformed media net of the zero-spend response, weighted by the coefficient and converted back into currency:
contribution[m] = sum_g sum_t beta[g,m] * delta[g,t,m]
* rpk[g,t] * pop[g] * kpi_scaleThe baseline is then defined as the residual — total fitted outcome minus the sum of channel contributions. Defining it that way guarantees the waterfall adds up exactly, which matters more in practice than attributing the intercept and the controls separately.
Average ROI is recomputed from these contributions rather than read from the sampled roi site. That is a deliberate round trip: if the derived-beta algebra in chapter 03 were wrong, the two would disagree, and the test suite would catch it.
source · engine/mmm/derived.py
Marginal ROI
Average ROI answers “was this worth it”. Marginal ROI answers “should I spend more”, and it is the number that should drive reallocation. Under saturation it is strictly below average ROI, and the gap is the whole reason a high-ROI channel can still be the wrong place for the next dollar.
spend' = spend * (1 + 0.01 * e_m)
mroi[m] = (outcome(spend') - outcome(spend))
/ (total_spend[m] * 0.01)It is a finite difference rather than an analytic derivative because the quantity being differentiated is a full forward pass — adstock, saturation, geo aggregation and unit conversion — and the finite difference is guaranteed to be the derivative of the thing actually computed rather than of a hand-derived expression that could drift from it.
Response curves
A channel’s saturation depends on how its spend is distributed across weeks: the same annual budget concentrated into four flights hits the bend in the curve far harder than the same money spread evenly. Sweeping a flat level would therefore describe a media plan nobody is proposing. Scaling the observed pattern keeps the curve answerable to a real plan.
ROI units are not always a multiple