MMM.add_lift_test#

MMM.add_lift_test(experiment, channel, x, delta_x, dist=<class 'pymc.distributions.continuous.Gamma'>, name='lift_measurements', **dim_kwargs)[source]#

Add a CausalPy experiment result as a lift test calibration.

Convenience method that converts an ExperimentResult into the lift test DataFrame format and passes it to add_lift_test_measurements().

Parameters:
experimentExperimentResult

The experiment result from experiment() or run_experiment().

channelstr

The marketing channel name. Must be present in channel_columns.

xfloat

The baseline spend level for the channel during the experiment.

delta_xfloat

The change in channel spend during the experiment.

disttype[pm.Distribution], optional

The distribution to use for the likelihood, by default pm.Gamma.

namestr, optional

The name of the likelihood contribution, by default "lift_measurements".

**dim_kwargsstr

Dimension values for the lift test, e.g. geo="US". Keys must match the model’s dims.

Raises:
RuntimeError

If the model has not been built yet.

KeyError

If the channel or dimension values don’t match the model.

See also

experiment

Run a CausalPy experiment.

add_lift_test_measurements

Add raw lift test measurements.

Examples

import causalpy as cp

result = mmm.experiment(
    experiment_type="its",
    data=df_experiment,
    treatment_time=pd.Timestamp("2024-01-01"),
    formula="y ~ 1 + t",
    model=cp.pymc_models.LinearRegression(),
)

mmm.add_lift_test(
    experiment=result,
    channel="tv",
    x=1000.0,
    delta_x=200.0,
    geo="US",
)