google / lightweight_mmm

LightweightMMM 🦇 is a lightweight Bayesian Marketing Mix Modeling (MMM) library that allows users to easily train MMMs and obtain channel attribution information.
https://lightweight-mmm.readthedocs.io/en/latest/index.html
Apache License 2.0
865 stars 177 forks source link

Forcing an external variable to provide negative contribution #323

Open karjeswal opened 3 months ago

karjeswal commented 3 months ago

Hi,

I've got a model that I'm happy with but I have one external variable that keeps giving be positive contribution regardless of what I'm trying. The variable in question is competitor media spend with the rationale, the more competitors spend it would affect the number of sales negatively for set business.

I've set up the following list of data (some non media variables are included in media as I need to control them to be positive):

pic 1

I then try and play around with the model.py source code for the ext_negative factors, see image below. Whatever I try to force these values to be I either end up with:

  1. A very poor model that deteriorates as the values inputed completely ruin the fit.
  2. Values that hardly move at with a similar model fit as in my first attempt. pic 2

I've also tried to run this with a HalfNormal distribution instead of TruncatedNormal but without any success. My ultimate goal would be to get within a certain range of contribution for competitor spend (as there was an MMM previously done that had this as negative). Ideally I would like to control this in a similar fashion as for media variables but being able to keep them as negative.

Lastly, I've also tried to include them in the media vars part and tried to force them to be negative in the media tuning params, but I still end up with only positive cases.

pic 3

Any guidance would be much appreciated and if you need more info regarding the code, let me know.

Cheers.

Thanks,