generate_experiment_fixture#

pymc_marketing.mmm.experiment_design.fixture.generate_experiment_fixture(channels=None, saturation='logistic', adstock='geometric', true_params=None, n_weeks=104, noise_std=0.5, intercept=10.0, l_max=8, normalize=True, seed=42, fit_model=True, n_chains=2, n_draws=2000, n_tune=1000, target_accept=0.9)[source]#

Generate a realistic InferenceData fixture for testing.

Simulates spend data, applies a known DGP, and (optionally) fits a PyMC-Marketing MMM to produce realistic posterior samples.

Parameters:
channelslist[str] | None

Channel names. Defaults to ["tv", "search", "social"].

saturationstr

Saturation type. Only "logistic" is supported.

adstockstr

Adstock type. Only "geometric" is supported.

true_paramsdict | None

Ground-truth parameters per channel. Each value is a dict with "lam", "beta", "alpha" keys. If None, uses defaults.

n_weeksint

Number of weeks to simulate.

noise_stdfloat

Standard deviation of observation noise.

interceptfloat

Intercept of the DGP.

l_maxint

Maximum adstock lag.

normalizebool

Whether adstock weights are normalised.

seedint

Random seed.

fit_modelbool

If True, fits an actual MMM (slow, 2-5 minutes). If False, creates synthetic posterior samples from the true parameters with added noise (fast, for testing).

n_chainsint

Number of MCMC chains (only used if fit_model=True).

n_drawsint

Number of MCMC draws per chain (only used if fit_model=True).

n_tuneint

Number of tuning steps (only used if fit_model=True).

target_acceptfloat

Target acceptance rate (only used if fit_model=True).

Returns:
InferenceData

An ArviZ InferenceData suitable for ExperimentDesigner.from_idata().