
This website serves two functions: to share the code from our book, and to provide a place where people can ask and answer questions about Bayesian meta-analysis.
We launched on publication day, 27 June 2025, with the code for the basic Bayesian meta-analysis models (common effect, random effects, and arm-based versions of these) in BUGS/JAGS, Stan, brms, and Stata. We are aiming to have all the code related to the book online here by September 2025.
Through the book, you will sometimes see a computer symbol in the margins, like this:

This indicates that there is some corresponding code on the website. At the bottom of this page, we list all the icons and give links to the posts where their code appears on this website. These are getting populated all the time and you will see the hyperlinks appear as this happens.
However, there is more here than just indicated by the computer icons: we have elaborated, given all the possible translations into different software (in the book, we mostly show R and BUGS code as a lingua franca after Part 1), and of course, users can add their own suggestions and queries in the comments.
Using the code
The best way to use the code provided here is as a spring board to your own ideas that suit your systematic review. You will have a unique evidence base and a very specific question. In particular, it is vital that you choose your own prior distributions and are able to justify the choice.
Although it is tempting to copy code from here and get started immediately, we strongly recommend that if you are new to Bayesian meta-analysis, you play first with some of the data files we provide, comparing the results you obtain to those in the book. It can also be useful to try the same model out on simulated data. You can introduce deliberate problems to the data and see what happens, and change the priors too. Finally, the experience you gain this way can be applied to the project you need to complete in earnest, to tailor the model and to justify all the choices. Be innovative and be transparent!
Start with the common effect posts for the software of your choice. These realte to Chapter 3 of the book. If you are undecided on software, take a look at all of them and the wider comparison in Chapter 2 and in this summary table. Next, move to the random effects post (Chapter 4). If you are aiming for network meta-analysis, or have some trouble with unreported study statistics, move on to the arm-based post (Chapter 8), and then move to network meta-analysis (Chapter 9). The “tags” section below will show you how to filter posts to the software of your choice.
JASP is the exception, with a single overview post and more direction in the book. We are likely to add more JASP content as it is rapidly expanding. We will also add more software options if they emerge or are requested by readers.
We don’t give prior distributions in any of the code templates on this site, because we don’t want you to copy and paste the code without considering the relevance of the prior. See Chapters 2-4 of the book for definition and discussion of priors, Chapter 6 regarding the elicitation of expert opinions, and Section 12.2 for using a prior to update a previous meta-analysis.
Signing up
You can read the posts here without registering, though if Bayesian meta-analysis is going to be part of your work, we suggest you register as a user. That way, you can choose if you would like to to receive email digests of activity on the site, or to be notified of new posts. You will also be able to ask questions, and to reply to other people’s questions.
To focus these discussions, we chose to make the site blog-focused. Authors create topics, and users can comment and discuss those, even long after they were originally posted. This helps to get all the conversation about a particular type of model in a particular software into one place.
If you want to ask about your random-effects BMA with publication bias using JAGS, for example, find the post about publication bias models in BUGS and JAGS, and add a comment there asking your question. If you see someone else asking, and you think you can help, reply! You can subscribe for digests of activity in the usual WordPress blog way, by email or an RSS reader.
Asking a question
Find the post relating to your software and your meta-analysis model, and add your question as a comment underneath. You can use LaTex code for equations, just wrap it in two dollar signs at the beginning and end, for example $$E = mc^2$$. Other users (including Robert and Gian Luca) will see that you have posted it and can reply to you to help out. Bayesian meta-analysis is still a rare activity, and so most of us are isolated from each other. You may be the only user of Bayesian methods in your organisation, for example. We want this website to be a way we can support each other.
Code of conduct
We want to set a minimal set of rules. Be helpful and be kind. Everybody is welcome here. We will take down comments that are detrimental to a healthy, happy, productive community of Bayesian meta-analysts, and will bar users who won’t behave. Off-topic posts will be removed.
Tags
This is how we use tags like #nma in this website’s posts.
These are typed at the end of posts, so you can just search for them. Every tag is lowercase throughout (though search and filtering by tags is not case-sensitive).
Posts containing code from the book get tagged #repo (for repository), also the relevant software, for example #bugs, and then the combination #bugs-repo. Filtering only the #repo posts will show you code from the book (plus elaborations!).
Other software tags are: # jags, #stan, #stata, #bayesmeta, #brms, #jasp, #pymc. PyMC gets repo tags, even though it isn’t in the printed book, becuse we regard it as such an important option for Bayesian meta-analysts. Perhaps in due course, we will add others too, such as the R package multiNMA.
Posts about BUGS (for example) but not examples from the book get #bugs but not #bugs-repo or #repo.
The buttons on the front page under “code repository” should lead to lists of blog posts with the relevant #xyz-repo tag.
Datasets get their own tags too; those from the book are: #data-greentea, #data-aceivarb, #data-thrombo, #data-ganglio, #data-exercise.
Other methods have tags like #nma for network meta-analysis.
How do I share news of an event?
There is a pinned post about events, like courses, workshops, or meetups. Add a comment to that. Remember to give dates, times with time zone, and a link to further information. You can post about commercial (for-profit) events too, as long as they are relevant to Bayesian meta-analysis.
Basic models
There are posts for common effect and random effects models (CE and RE) in each of the software options we provide. You can get to these via the “Code Repository” section on the homepage, or you can search in the posts with the software hashtag, like #JAGS or #brms.
If you are new to the subject (almost everyone is), then start with these CE and RE models. They relate to content in Chapters 3 and 4 of the book. Everything in Part 3 of the book (Chapters 8-17) builds on these.
Within each post, we consider an arm-based model and a contrast-based model. The arm-based models use two estimates from each study, one for each arm. For example, in the green tea dataset, we have mean weight loss in the green tea arm, and also in the control arm. Each of those means also has its standard error, which can be calculated from the standard deviation and the sample size. When the event is binary, there is no standard error, just a numerator and denominator. Arm- and contrast-based models are compared in Chapter 8 of the book.
The contrast-based models use only one estimate from each study, which is the contrast between the arms. In the book we mostly call this the intervention effect, because that term is most familiar to researchers, but we should bear in mind that we are not all working with randomised controlled trials and other experimental studies that allow this causal interpretation. The contrast could be a mean difference, log odds ratio, etc, but in each case it will have a standard error.
We give code here for contrast statistics with sampling distributions that rapidly converge to the normal pdf, for example the log odds ratio, not the odds ratio. If you are unsure about the underlying statistical theory of study statistics, review Chapter 1 of our book; another, more mathematical, reference that we often recommend is the book “Statistical Inference” by Casella and Berger.
Network meta-analysis
Most published Bayesian meta-analyses today are network meta-analyses (NMAs), which compare more than two intervention options. These build on the basic models, so it is important to get familiar with the basics before progressing (as the Cochrane Handbook says, “Do not start here!”) Then, you will find NMA code available for each of the software options where it is possible.
Is it OK to write “BMA”?
Yes, we think so!
Writing to us
Suppose you have an idea for a new post, maybe a particularly illuminating example, a recent publication, or news of a conference. We want to know about it! You can find us on LinkedIn (Robert and Gian Luca have personal accounts), or on Bluesky, Mastodon, or Twitter/X as @bma_net or @bma-net. See the brown banner at the top of the page for these links. It’s not too hard to find our email addresses either…
Who runs this site?
bayesian-ma.net is entirely non-commercial (if we recommend other sites, we do so impartially) and run by volunteers, mainly authors Robert Grant and Gian Luca Di Tanna. The hosting and associated costs are donated by them.
All the icons from the book
These are the posts dealing with each of the computer icons in the book (and a few extras). We are adding these regularly. Page numbers here are from the printed copy; e-books may differ.
- Section 1.2, pages 7 & 8: sampling from a known population
- Section 1.4, page 12: sampling for a contrast
- Section 1.4.2, page 13: sampling from paired data
- Section 2.2.1, page 21: snow leopards example (simulated)
- Section 2.2.3.2, page 24: common density functions for priors
- Section 2.4.1, page 31: MCMC for univariate models
- Section 2.5.2, page 54: bootstrap estimation of Monte Carlo error
- Section 2.5.4, page 57: prior and posterior predictive checks
- Section 3.5, pages 68 & 72: simulation of non-Bayesian CE meta-analysis
- Section 3.6: software implementation of basic CE models: see the posts for various software options: BUGS and JAGS | Stan | Stata | brms | bayesmeta | JASP | PyMC
- Section 4.1, pages 92 & 93: simulation of non-Bayesian RE meta-analysis
- Sections 4.4 and 4.6: software implementation of basic RE models: see the posts for various software options: BUGS and JAGS | Stan | Stata | brms | bayesmeta | JASP | PyMC
- Section 4.8.1, page 126: examining RE meta-analysis when heterogeneity is very small
- Section 4.8.4, page 127: predictive inference for a future trial
- Section 4.8.5, page 127: sensitivity analysis with priors
- Chapter 5: various conversion functions for data extraction, also priors for uncertain statistics and typos
- Section 6.2.1, page 149: example of using SHELF R package for prior elicitation
- Section 6.3, page 152: example of maximum likelihood estimation for stones-in-bins elicitation
- Section 6.4, page 154: examples of kernel and kudzu densities for elicited prior histograms
- Section 7.3, page 159: tailored forest plots for BMA output in R and Stata
- Chapter 8: see the posts for arm-based models in various software options: BUGS and JAGS | Stan | Stata | brms | PyMC
- Section 9.2, page 190: NMA: see the posts for various software options
- Chapter 11, pages 212, 214 & 216: unreported statistics: see the posts for various software options
- Chapter 12, page 228: illustration of updating / living systematic review
- Section 14.1, page 246: dichotomised outcomes
- Section 15.2.3, page 254: multivariate meta-analysis with covariance matrices

