bmlm: An R package for Bayesian MultiLevel Mediation models

bmlm is an R package providing convenient methods for Bayesian estimation of multilevel mediation models using Stan.

For an example, please see a short introduction to bmlm.


To install the latest stable version of bmlm from CRAN, run


The latest version (with possible added functionality) of bmlm requires devtools for installation. If you don't have the devtools package installed in R, first run this line:


Then proceed to install bmlm:

devtools::install_github("mvuorre/bmlm", args = "--preclean")

(Additional installation instructions here.)


bmlm ships with an example data set from Intensive Longitudinal Methods: An Introduction to Diary and Experience Sampling Research (Bolger & Laurenceau, 2013, chapter 9). To estimate the multilevel mediation model presented in that chapter, run:

fit <- mlm(BLch9)

After a while, you will have a joint posterior distribution of plausible parameter values from the model applied to this data. Inspect the model:



Please contact the author of the package for questions and suggestions. I recommend creating a new issue on GitHub.