Pymc-marketing - set custom prior for subset of elements in beta_channel?

I’ve been testing the latest version of pymc-marketing, which currently allow for custom prior by changing the model_config dictionary.

I can see how to priors can be configured across all beta_channels, but i’d like to know if i am able to set a custom distribution to a single one of my beta_channels. Specifically, i’d like to force a specific channel effect to be negative (currently they are necessarily positive, due to the use of HalfNormal distributions).

1 Like

It’s potentially not the best solution into the long term, but for now is it possible to make your data negative - e.g if you have 100 impressions in week 1, they are adjusted to be -100 impressions, and then the end impact will be negative (even with a positive coefficient)


Thank you! that indeed works.

I’d like to achieve a similar results by changing the prior distribution on the coefficient for that variable, but i am having a hard time properly encoding prior knowledge and tests for specific channels using this package.

I am showing you code for the next version of pymc-marketing which should be out pretty soon.

The docs are updated in this link: MMM Example Notebook — pymc-marketing 0.1.1 documentation

You can specify the parameters of the sigma prior on the coefficients beta_channel. If you pass a vector like [1, 10] (if you have two channels), you get different priors for them:

custom_beta_channel_prior = {'beta_channel': {'sigma': [1, 10], 'dims': ('channel',)}}
my_model_config = dummy_model.default_model_config| custom_beta_channel_prior

You then pass my_model_config when creating the MMM model. We should probably consider allowing arbitrary prior distributions, not just HalfNormal. Mixing of different distributions might be hard though.

1 Like

An issue about increasing flexibility is here: Allow specifying prior distribution in MMM models via config · Issue #294 · pymc-labs/pymc-marketing · GitHub

1 Like

Thank you! i’ll keep an eye out for these updates. As you mentioned, having specific distributions is for each channel could be convenient. In my case, there are channels and adstock level for which i am quite confident in the coefficient that they have, due prior experiments. So i would rather not estimate them again, but just set prior specifically to those channels, which are closer to the coefficient value i am confident in.

1 Like

Some more flexible distribution like Gamma would allow you to parametrize with mu and sigma, and then you could set those you are confident easily with those parameters.

Like pm.Gamma("beta_cannel", mu=[1, 1], sigma=[10, 0.1]) (using PyMC API, but the ideas is the same)

1 Like