Incrementality.spend_over_contribution#

Incrementality.spend_over_contribution(frequency, period_start=None, period_end=None, include_carryover=True, num_samples=None, random_state=None)[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.

period_start, period_endstr or pd.Timestamp, optional

Date range for computation.

include_carryoverbool, default=True

Include adstock carryover effects.

num_samplesint or None, optional

Number of posterior samples to use. If None, all samples are used.

random_stateRandomState or Generator or None, optional

Random state for reproducible subsampling.

Returns:
xr.DataArray

Spend per unit contribution with dimensions (chain, draw, date, channel, *custom_dims). Zero contribution results in Inf; zero spend results in NaN.

Examples

>>> cac = mmm.incrementality.spend_over_contribution(
...     frequency="monthly",
... )