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

Modeling does not succeed because MCMC does not converge #303

Open
Kazuto-Andou opened this issue Sep 25, 2024 · 1 comment
Open

Modeling does not succeed because MCMC does not converge #303

Kazuto-Andou opened this issue Sep 25, 2024 · 1 comment

Comments

@Kazuto-Andou
Copy link
Collaborator

Situation
In some data sets,

model_diagnostics = visualizer.ModelDiagnostics(meridian)
model_diagnostics.plot_rhat_boxplot()

at runtime,

MCMCSamplingError: MCMC sampling failed with a maximum R-hat value of {very high R-hat value}

error, and I have not been able to find the cause of the problem and have not been able to resolve it.
Also, when this error occurs, when we call visualizer.MediaSummary(),
For all media, the incremental kpi of the posterior distribution is abnormally large and the cpik is extremely small.
The puzzling thing is that different datasets have different degrees of this error. One data set does not experience this error at all, another data set does not experience it in version 0.4.0 and version 0.5.0 does. (Note that these two data sets, and the three data sets discussed below, were modeled by different analysts.)
Have you noticed a similar problem?
If you have any idea of the cause, it would be appreciated if you could let us know.

What we did

  • Changed the dataset: We tried 3 different datasets with no success, thinking it might be a factor specific to the dataset we used.
    One of the three was a dataset that converged successfully with LightweightMMM. 
    Note that Meridian_Getting_Started produced successful results.
  • Change of versions: We tried the above three datasets with versions 0.3.0~0.6.0, but they did not work.
  • Reexamination of data formatting: We examined multicollinearity and removed columns with many zeros, but it did not work.
  • Tuning of MCMC parameters: I tried using larger values than the default parameters to the extent that it did not crash, but it did not work.
meridian.sample_prior(500)
meridian.sample_posterior(n_chains=10, n_adapt=500, n_burnin=300, n_keep=1000)
  • Adjusting the prior distribution: For cpik_prior, I tried making the mean extremely large/small and the variance small, but it did not work.
  • Adjustment of knots: In addition to the default, I also tried the pattern of monthly separations, but it did not work.
  • Adjustment of environment: We asked a colleague who did not experience the error to run the script that caused the error, and the same error occurred.
@brendalewisprice
Copy link
Collaborator

Sorry to hear you are having such trouble getting convergence!

In case you haven't looked at our documentation on getting MCMC convergence (although it sounds like you might have already) it can be found at Getting MCMC convergence.

You've already tried out many of our suggestions in the documentation, but there are a few more that you didn't mention trying yet: 1) exploring the strength of variation in your media or controls, 2) reassessing the priors and potentially trying other distributions based on your business sense, 3) adjusting other options besides the knots (ie, unique_sigma_for_each_geo or media_effects_dist), 4) turning off the geo hierarchy assumption.

One other thought. You didn't specify if your model is at the national or geo level. If at the geo level, you can also consider restricting your model to set of "top" geos that cover most of the spend - the top 20 by spend or population could be a good place to start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants