Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward pass on a given spend #451

Closed
wd60622 opened this issue Dec 3, 2023 · 3 comments
Closed

Forward pass on a given spend #451

wd60622 opened this issue Dec 3, 2023 · 3 comments
Labels
enhancement New feature or request MMM

Comments

@wd60622
Copy link
Contributor

wd60622 commented Dec 3, 2023

I've been playing around with how some amount of money contributes to the upcoming sales in order to understand the adstock functions. I wonder if others have used this to build intuition of the model fit.

The general sense of the function is

def new_spends_contributions(spends: np.ndarray, mmm: DelayedSaturatedMMM, spends_leading_up: np.array = None) -> xarray.core.dataarray.DataArray: 
    """
    Args: 
        spends: vector of new spends for all the channels
        mmm: model but would be self if a method 
        spends_leading_up: vector of spends in the weeks leading up for each channel that are carried over via adstock function 
    Returns: 
        Forward pass of contributions for the next coming weeks for each channel. (draw, channel, weeks_since_spend)
    """

This evaluates the adstock, the saturation, beta coefficient, (and does the inverse transform)

It doesn't give a good sense of the saturation of a spend unless it is evaluated across different spends, but I think it give some intuition on how long (and how much) a certain amount goes because of the adstock function.

Here is an example visualiation based on this data that compares two different spends. For instance, I see both channels spends last ~ 4 weeks. I don't think there are currently any cuts of the parameters that would show this specifically

this-weeks-spend

I would love to hear any thoughts and if this would be helpful to understand adstocks after fit (especially if more will be added to the mix eventually #447)

@cetagostini
Copy link
Contributor

cetagostini commented Dec 6, 2023

Hey hey!

In my opinion, this information is incredibly useful - even tremendously useful. I was looking to dedicate some time to this myself, so seeing that you have already found a way to apply it is fantastic.

This graph is particularly helpful to me because it allows me to estimate how many incremental sales occur at a certain level of spending. With this prior information, I can generate experiments and have another layer to validate the results of my models and eventually, update my beliefs.

Additionally, by looking at this graph, I can easily assess how well the model estimates this effect. I mean, we are working with two transformations and beta, and I have had times where delivering priors of a specific transformation caused the model to compensate by adjusting another transformation in which it doesn't have strong priors.

Most importantly, I see this graph as a straightforward way to explain this concept to people who are not familiar with MMM. If I were to show this to my stakeholders tomorrow, they would be able to understand it easily.

It's quite a secret you've kept, Haha! If you need any help, I'd be happy to lend a hand with putting this PR out. We could even show it before the next release (?)... Perhaps to optimistic.

cc: @wd60622

@wd60622
Copy link
Contributor Author

wd60622 commented Dec 7, 2023

Hey @carlosagostini
Thanks for the feedback and interest! I put my existing code in the PR linked above. Feel free to add some direct comments there

I'm glad that it seems useful, I agree. I think it focusing on a given spend's contribution is insightful too even if it doesn't paint the whole picture.

I'm hearing that you'd like to see use this visualizing prior as well. I think that would be very easy to setup! A DataArray from the prior could be used instead of the idata with posterior in the pm.sample_posterior_predictive function. I set up an argument prior in order to leave some space for that.

I will add some more details in the PR

@wd60622
Copy link
Contributor Author

wd60622 commented Apr 25, 2024

Completed with #456

@wd60622 wd60622 closed this as completed Apr 25, 2024
@wd60622 wd60622 added MMM enhancement New feature or request labels Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request MMM
Projects
None yet
Development

No branches or pull requests

2 participants