Incrementality.spend_over_contribution#
- Incrementality.spend_over_contribution(frequency, start_date=None, end_date=None, include_carryover=True, num_samples=None, random_state=None, central_tendency='median')[source]#
Compute spend per unit of incremental contribution.
Reciprocal of
contribution_over_spend(). The interpretation depends on the model’s target variable – e.g. CAC (Customer Acquisition Cost) when the target is customer count.- Parameters:
- frequency{“original”, “weekly”, “monthly”, “quarterly”, “yearly”, “all_time”}
Time aggregation frequency.
- start_date, end_date
strorpd.Timestamp, optional Date range for computation.
- include_carryoverbool, default=True
Include adstock carryover effects.
- num_samples
intorNone, optional Number of posterior samples to use. If None, all samples are used.
- random_state
RandomStateorGeneratororNone, optional Random state for reproducible subsampling.
- central_tendency{“median”, “mean”}, default=”median”
Central tendency of the counterfactual predictions. Only meaningful for non-linear links; see
compute_incremental_contribution().
- Returns:
xr.DataArraySpend per unit contribution with dimensions
(chain, draw, date, channel, *custom_dims). Zero contribution results in Inf; zero spend results in NaN.
- Raises:
ValueError,NotImplementedErrorDelegates to
contribution_over_spend(); see there for the full list.
- Warns:
UserWarningDelegates to
contribution_over_spend(); see there for the full-axis fallback warning.
Examples
>>> cac = mmm.incrementality.spend_over_contribution( ... frequency="monthly", ... )