MMMIDataWrapper.get_contributions#

MMMIDataWrapper.get_contributions(original_scale=True, include_baseline=True, include_controls=True, include_seasonality=True)[source]#

Get all contribution variables in a single dataset.

For identity-link models, contributions are computed by multiplying log-space values by target_scale. For log-link models, a conserving decomposition is used: the total media counterfactual lift is split across channels proportionally to their log-space shares, and all non-media effects are folded into baseline, so the returned components sum exactly to \(\hat y\).

This conserving decomposition differs from the counterfactual decomposition in compute_counterfactual_contributions_dataset(), whose per-component lifts do not sum to \(\hat y\) under the log link. See _get_conserving_contributions_log_link() for the precise relationship. Under the log link the prediction uses \(\exp(\mu)\), the conditional median of the LogNormal response (not its mean).

Parameters:
original_scalebool, default True

Whether to return contributions in original scale

include_baselinebool, default True

Include intercept/baseline contribution

include_controlsbool, default True

Include control variable contributions (if present)

include_seasonalitybool, default True

Include seasonality contributions (if present)

Returns:
xr.Dataset

Dataset with all contribution variables

Raises:
ValueError

If original_scale=True and target_scale is not found in constant_data