diff_diff.to_meridian_roi_prior#
- diff_diff.to_meridian_roi_prior(*, incremental_outcome, incremental_outcome_se, spend, parameter='roi_m', se_widening=1.0)[source]
Build a Meridian lognormal ROI/mROI prior from scoped experiment result(s).
Per experiment
roi = incremental_outcome / spendwith standard deviationincremental_outcome_se / spend * se_widening. Multiple experiments for the same channel are pooled with spend weights - the spend-weighted average ROI the Meridian FAQ suggests for multiple experiments (citing section 3.4 of Google’s MMM calibration whitepaper):roi_mean = sum(w_i * roi_i)withw_i = spend_i / sum(spend). The pooledroi_sd = sqrt(sum((w_i * sd_i)^2))is this library’s uncertainty propagation for that average (treats experiments as independent - widen viase_wideningwhen experiments share controls or windows). The pooled mean/sd map to lognormal(mu, sigma)via Google’s closed form.The caller supplies the scoped estimand.
incremental_outcomeis the total incremental outcome the experiment measured, matching the estimand of the target prior: forparameter="roi_m"that is the outcome attributable to the channel’s spend against a zero-spend counterfactual (a full holdout), divided here byspend= the channel’s total spend over the window; forparameter="mroi_m"it is the marginal outcome of the spend change, divided by that spend change. Sign, aggregation, and population are the caller’s responsibility - diff-diff does not rescale a headline ATT.- Parameters:
incremental_outcome (float or sequence of float) – Total incremental outcome per experiment (the estimand matching
parameter), in the same currency/units as the MMM. Must be finite; the pooled ROI must be positive (lognormal support).incremental_outcome_se (float or sequence of float) – Standard error of
incremental_outcome(finite, positive), computed for the caller’s aggregation.spend (float or sequence of float) – Spend the incremental outcome is divided by (finite, positive): the channel’s total spend over the window for
roi_m, or the spend change formroi_m.parameter ({"roi_m", "mroi_m"}, default "roi_m") – Which Meridian prior the estimate informs.
roi_mis the return on the channel’s full spend (a full-holdout / zero-spend estimand);mroi_mis the marginal return of a spend change. Under saturation these differ, so the caller declares which theirincremental_outcomemeasures; the returned prior and.to_code()target that parameter with its own Meridian default for non-experiment channels.se_widening (float, default 1.0) – Multiplier on each experiment’s ROI standard deviation (finite, positive). Values above 1 encode skepticism about experiment-to-MMM transferability.
- Returns:
Pooled
roi_mean/roi_sd, the lognormalmu/sigma, the targetparameter, per-experiment detail, plus.to_dict()and the channel-scoped.to_code()snippet helper.- Return type:
- Raises:
ValueError – On an invalid
parameter, non-positivespend/se/se_widening, non-finite inputs, broadcasting mismatches, empty inputs, a non-positive pooled ROI mean (lognormal support), or non-finite scaled/pooled results.