Skip to content

Bayesian Analysis Recipes


I've recently been inspired by how flexible and powerful Bayesian statistical analysis can be. Yet, as with many things, flexibility often means a tradeoff with ease-of-use. I think having a cookbook of code that can be used in a number of settings can be extremely helpful for bringing Bayesian methods to a more general setting!


There is one notebook per model. In each notebook, you should end up finding:

  • The kind of problem that is being tackled here.
  • A description of how the data should be structured.
  • An example data table. It generally will end up being tidy data.
  • PyMC3 code for the model; in some notebooks, there may be two versions of the same model.
  • Examples on how to report findings from the MCMC-sampled posterior.

It is my hope that these recipes will be useful for you!


My hypothesis here follows the Pareto principle: a large fraction of real-world problems can essentially be modelled with a core collection of models, each of which have a Bayesian interpretation.

In particular, I have this hunch that commonly-used methods like ANOVA can be replaced by conceptually simpler and much more interpretable Bayesian alternatives, like John Kruschke's BEST (Bayesian Estimation Supersedes the T-test). For example, ANOVA only tests whether means of multiple treatment groups are the same or not... but BEST gives us the estimated posterior distribution over each of the treatment groups, assuming each treatment group is i.i.d. Hence, richer information can be gleaned: we can, given the data at hand, make statements about how any particular pair of groups are different, without requiring additional steps such as multiple hypothesis corrections.

Further reading/watching/listening




Got Feedback?

There's a few ways you can help make this repository an awesome one for Bayesian method learners out there.

If you have a question: Post a GitHub issue with your question. I'll try my best to respond as soon as possible.

If you have a suggested change: Submit a pull request detailing the change and why you think it's important. Keep it simple, no need to have essay-length justifications; this also makes things easier for me to review. As usual, I will get back to you as soon as I can.