Hey,
I’m wondering what the best way of encoding a multi-channel lift test to calibrate a model. e.g. one experiment evaluating Facebook, Google, Snapchat etc.
Does PyMC have under the hood functionality to manage this a bit like Robyn does? e.g. In Robyn, you encode the test details along with (‘Facebook’ + ‘‘Google’ + ‘Snapchat’) and I believe it apportions out the result based on spend.
Is it better to encode them as three individual channels with outcomes divided out based on a rule?
We don’t have a native way to support this, nevertheless a simple way to make it will be create a custom deterministic with the sum of channels index A,B,C over time, and force this variable with potential to certain value.
Something like this could work:
period_mask = slice(99, 120) # select days between 100 and 120
with mmm.model:
pm.Deterministic("variable_sum_of_g_s_f", mmm.model["channel_contribution"][:, 1:4].sum(axis=-1)) # assuming channel contribution shape date, channel and channels 1,2,3 are facebook google snapchat.
tol = 1e-8
pm.Potential(
"hard_constraint",
pm.math.switch(
pm.math.all(pm.math.abs(mmm.model["variable_sum_of_g_s_f"][period_mask] - target_values) < tol),
0.0,
-np.inf,
)
)