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
829 stars 172 forks source link

Question: How to model time dependent features in the fit and predict method? #259

Open MarkusSagen opened 8 months ago

MarkusSagen commented 8 months ago

I have been experimenting a bit with LightweightMMM and marketing mixed models and came across this blog post.

https://docs.google.com/spreadsheets/d/1A5XqvMegNanQTVsr7mhHP_BcjwoDSh1D9ZgDxKUvb4A/edit?pli=1#gid=0 https://getrecast.com/seasonality/

we model an ROI for every channel, for every day. Most media mix models (including the popular open-source package Robyn) only model a static ROI, which is the average marketing impact across all time periods. It will tell the hot wing-seller that their ads are just as effective on game day as they are the day after.

To allow model coefficients to change with the seasons requires a more advanced approach. A full treatment is quite technical and beyond the scope of this post, but suffice it to say that Recast’s model incorporates two assumptions into a Gaussian Process prior: today’s ROI should be similar to yesterday’s (which enforces smooth changes over time), and that today’s ROI should be similar to last year’s ROI on the same date (which allows for seasonal cycles). We’re able to do that, because we use a Bayesian approach, which is flexible enough to let us incorporate prior knowledge about each parameter.

I am curious how something like this could be implemented in LightweightMMM?

Would love to work on this if give some guidance on how this could be done

I've seen that Uber's Orbit model does incorporate this and is built in pyro: https://getrecast.com/uber-orbit/

See: https://github.com/google/lightweight_mmm/issues/258

becksimpson commented 8 months ago

@MarkusSagen I've been pondering on this as well. I know of the example Dynamic Linear Models Pyro, this allows the day-on-day consistency, seen in Uber's Orbit Model, though this is a less complex, and more computationally intensive approach than the Kernel-Smooth method used in Orbit. Recast have previously stated they do not treat seasonality as independent effects as commonly seen in MMM's but as interactive, leading to boosts in the effectiveness of advertisement, and underlying sales/KPI. "Your marketing performs better when demand is high." Not an independent effect.

'''At Recast, we actually want to measure two different effects of seasonality:

1) The first effect is the effect on the organic demand for a brand's products.

2) The second effect is the impact that is won through marketing: how much more effective is it getting due to the season versus how much is just due to the marketing itself? ''' From this it allows time varying effectiveness of marketing and baseline.

"Controlling for seasonality in your analysis will give all the credit to the season, which means you’ll under-credit the impact of marketing on your sales." We'd expect capturing multiplicative seasonal effects will raise the credit given to marketing.

"We model seasonality by layering in the assumption (and since we’re Bayesian, this is accomplished through our priors), that “today is like a year ago”. The time-varying variables must have deltas similar year on year?

"we model an ROI for every channel, for every day." Each channel has a time varying effectiveness coefficient.

"today’s ROI should be similar to yesterday’s (which enforces smooth changes over time), and that today’s ROI should be similar to last year’s ROI on the same date (which allows for seasonal cycles)."

I am not aware of a way to write a time varying coefficient that respects seasonal patterns, while being allowed to vary over time across years, or at least none out of the box. I wonder if they just learn 365 drift terms for the period of one year, that are then replicated each year. You keep the seasonality but you start position can vary YoY. These are used to create time varying baseline, and marketing effectiveness that is channel specific.

I wonder if this can be simplified if you believe the relative changes of the seasonal effect are consistent across marketing channels/baseline i.e. same impact on effectiness/underlying sales. Then there is a single 1-prior multiplier that varies across time, that is multiplied against baseline and marketing effects. Although at that point would you be better with the original additive terms for seasonality (dow & fourier series), just 1-centered, to better explain that variation. Although be making it not-channel specific you do lose the ability to capture changing advertising effectiveness over time due to non-seasonal factors.

Ideally marketing channel change should be encoded as a change in customer susceptability based on time-of-year (seasonality) , and the effectiness of the marketing itself based on improved (hopefully) marketing optimisation over time. I wonder if there is potential for a 365-point seasonal multiplier (1-center) in combination with channel specific delta drift over time.

becksimpson commented 8 months ago

https://www.pymc-labs.com/blog-posts/modelling-changes-marketing-effectiveness-over-time/ PyMC actually previously discussed this. A global seasonality time-varying gaussian process. From which individual channels can inherit.