13 Bayesian regression in practice


Instead of hand-coding each Bayesian regression model, we can use the brms package (Burkner 2017). From now on, the exploration of Bayesian data analysis in this book will be centered on this package. This chapter provides a practical introduction to using this package.

badge-thermometer

As a running example, this chapter uses the world temperature data set. We are going to regress avg_temp against year in order to address the “research question” of whether the world is getting warmer. More concretely, we are going to address the question of whether the data provide reason to believe that, on the assumption of a linear relationship \(y = \beta_0 + \beta_1 x\), where \(x\) is a calendar year and \(y\) is the average surface temperature for that year, the coefficient \(\beta_1\) is credibly positive.58

The learning goals for this chapter are:

  • be able to use the brms package to run linear regression models and in particular, to:
    • specify a regression model with an R formula
    • interpret the summary output
    • extract posterior samples
    • change the default priors
    • test hypotheses about regression coefficients

References

Burkner, Paul-Christian. 2017. brms: An R Package for Bayesian Multilevel Models Using Stan.” Journal of Statistical Software 80 (1): 1–28. https://doi.org/10.18637/jss.v080.i01.

  1. Not to let the elephant sneak into the room: yes, there are much better models for this kind of data and research question than a simple linear regression model. But first things first.↩︎