A tutorial for brms

Last modified: 2026-08-17

Preface

These self-contained notes are intended for those that want a flexible R library to fit and visualize regressions and are willing or eager to do so with a Bayesian approach. To benefit from these notes it is necessary to know how functions, vectors, and data frames work in R, and to be familiar with linear regression. It is convenient but not necessary to be familiar with Bayesian statistics.

How to use these notes

These notes combine regular prose (like this sentence) with chunks of code. The prose explains what we do and the code shows us how to tell the computer to do it. An explicit code chunk looks like this:

# This is an explicit code chunk
2 + 2

An explicit code chunk like the one above is there for you to read and run it your own computer. All code chunks in a given section assume you ran the code chunks that came before, so make sure to run all the code in order. A folded code chunk like the one below is there only for reference, so you do not need to read it. Running a chunk like this is optional and the rest of the code will run fine without it. But you still need to run the explicit code chunks that precede a folded chunk.

A folded code chunk
# You do not need to run chunks like this
7 * 8

Creation of this document

These notes are published using Quarto (Allaire et al. 2026); the source code is available at https://github.com/CSCAR/workshop-brms.

You can switch between light and dark modes using the button in the top left corner of the screen. Dark mode reverses the colors of the images to reduce brightness. To show an image in its original colors, move your mouse over it (or press it if you are on a mobile device). All images link to more detailed full-size versions.

Contact information

If you have any questions or comments about these notes, you can contact Abner Heredia-Bustos ().

If you have additional questions about the use of brms tools or would like to contact CSCAR@ISR to set up an appointment, please send an email to .

Acknowledgments

We thank Abner Heredia Bustos and Brady West for their contributions to these notes.