Introduction

Forest plots display estimated parameters from multiple sources (studies, participants, etc.) in one figure. They are most commonly used in meta-analysis, where individual studies are used to inform an average, or meta-analytic, overall estimate. However, they can be seamlessly applied to other types of multilevel models–models in which parameters are assumed to vary among units. brmstoolsforest() function draws forest plots from brmsfit objects. They should be most useful for meta-analytic models, but can be produced from any brmsfit with one or more varying parameters.

The forest() function uses the fantastic ggridges R package in the backend, and assumes you’ve installed it. If you haven’t, forest() will return an error.

Random effects meta-analysis

We illustrate using a data set from the metafor package.

data("dat.bangertdrowns2004", package = "metafor")
dat <- dat.bangertdrowns2004 %>%
  mutate(study = paste0(author, " (", year, ")"), sei = sqrt(vi)) %>%
  select(study, yi, sei) %>%
  slice(1:15)

brms allows flexible specification of meta-analytic models.

Use forest() to draw the forest plot:

There are various options (see ?forest)

Data points can also be shown (note this probably only makes sense with a meta-analytic model):

Multilevel model

The forest() function can be seamlessly applied to any multilevel model.

We use example data from the lme4 package.

A multilevel model with varying intercepts and slopes (effect of Days):

If there are multiple varying parameters, users can input a variable name:

Or let the function automatically draw a plot with all the variables:

You can also turn off the ridgeline plots (densities)

forest(fit_ml, density = F, digits=0)