A synthetic data example of MMM
First, we’ll begin with the necessary imports and setup:
import warnings import arviz as az import matplotlib.pyplot as plt import numpy as np import pandas as pd import pymc as pm import seaborn as sns from pymc_marketing.mmm.transformers import geometric_adstock, logistic_saturation from pymc_marketing.mmm.delayed_saturated_mmm import DelayedSaturatedMMM warnings.filterwarnings("ignore") az.style.use("arviz-darkgrid") plt.rcParams["figure.figsize"] = [12, 7] plt.rcParams["figure.dpi"] = 100 %load_ext autoreload %autoreload 2 %config InlineBackend.figure_format = "retina"
Synthetic data generation
Let’s generate some synthetic data to test the model. We will generate data for two media channels, with adstock and saturation effects, and a trend and seasonality component. We’ll start by generating a DataFrame containing weekly...