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:
- channels
list[str] |None Channel names. Defaults to
["tv", "search", "social"].- saturation
str Saturation type. Only
"logistic"is supported.- adstock
str Adstock type. Only
"geometric"is supported.- true_params
dict|None Ground-truth parameters per channel. Each value is a dict with
"lam","beta","alpha"keys. If None, uses defaults.- n_weeks
int Number of weeks to simulate.
- noise_std
float Standard deviation of observation noise.
- intercept
float Intercept of the DGP.
- l_max
int Maximum adstock lag.
- normalizebool
Whether adstock weights are normalised.
- seed
int 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_chains
int Number of MCMC chains (only used if
fit_model=True).- n_draws
int Number of MCMC draws per chain (only used if
fit_model=True).- n_tune
int Number of tuning steps (only used if
fit_model=True).- target_accept
float Target acceptance rate (only used if
fit_model=True).
- channels
- Returns:
InferenceDataAn ArviZ InferenceData suitable for
ExperimentDesigner.from_idata().