Tutorials in Quantitative Methods for Psychology (Apr 2018)

User-friendly Bayesian regression modeling: A tutorial with rstanarm and shinystan

  • Muth, Chelsea,
  • Oravecz, Zita,
  • Gabry, Jonah

DOI
https://doi.org/10.20982/tqmp.14.2.p099
Journal volume & issue
Vol. 14, no. 2
pp. 99 – 119

Abstract

Read online

This tutorial provides a pragmatic introduction to specifying, estimating and interpreting single-level and hierarchical linear regression models in the Bayesian framework. We start by summarizing why one should consider the Bayesian approach to the most common forms of regression. Next we introduce the R package rstanarm for Bayesian applied regression modeling. An overview of rstanarm fundamentals accompanies step-by-step guidance for fitting a single-level regression model with the stan_glm function, and fitting hierarchical regression models with the stan_lmer function, illustrated with data from an experience sampling study on changes in affective states. Exploration of the results is facilitated by the intuitive and user-friendly shinystan package. Data and scripts are available on the Open Science Framework page of the project. For readers unfamiliar with R, this tutorial is self-contained to enable all researchers who apply regression techniques to try these methods with their own data. Regression modeling with the functions in the rstanarm package will be a straightforward transition for researchers familiar with their frequentist counterparts, lm (or glm) and lmer.

Keywords