Bayes Rules! An Introduction to Bayesian Modeling with R
Bayesian statistics?! Once an obscure term outside specialized industry and research circles, Bayesian methods are enjoying a renaissance. The title of this book speaks to what all the fuss is about: Bayes rules! Bayesian methods provide a powerful alternative to the frequentist methods that are ingrained in the standard statistics curriculum. Though frequentist and Bayesian methods share a common goal – learning from data – the Bayesian approach to this goal is gaining popularity for many reasons: (1) Bayesian methods allow us to interpret new data in light of prior information, formally weaving both into a set of updated information; (2) relative to the confidence intervals and p-values utilized in frequentist analyses, Bayesian results are easier to interpret; (3) Bayesian methods can shine in settings where frequentist “likelihood” methods break down; and (4) the computational tools required for applying Bayesian techniques are increasingly accessible. Unfortunately, the popularity of Bayesian statistics has outpaced the curricular resources needed to support it. To this end, the primary goal of Bayes Rules! is to make modern Bayesian thinking, modeling, and computing accessible to a broad audience.
Bayes Rules! brings the power of Bayes to advanced undergraduate statistics students and comparably trained practitioners.
Accordingly, the book is neither written at the graduate level nor is it meant to be a first introduction to the field of statistics.
At minimum, the book assumes that readers are familiar with the content covered in a typical undergraduate-level introductory statistics course.
Readers will also, ideally, have some experience with undergraduate-level probability, calculus, and the
R statistical software.
Please don’t go away if you don’t check off all of these boxes.
We provide all
R code and enough probability review so that readers without this background will still be able to follow along so long as they are eager to pick up these tools on the fly.
A reader with less calculus experience can also certainly follow along.
Though certain calculus concepts are important in Bayesian analysis (thus the book), calculus derivations are not.
The latter are limited to the simple model settings in early chapters and easily skippable should the reader choose.
Getting set up
Once you’re ready to dive into Bayes Rules!, take the following steps to get set up. First, download the most recent versions of the following software:
Next, install the following packages within RStudio:
Install rstan package by carefully following the directions at https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started.
Install a set of data wrangling and Bayesian packages by typing the following in your console:
install.packages(c("tidyverse", "janitor", "rstanarm", "bayesplot"), dependencies = TRUE)
Install the bayesrules package which contains some data sets and functions we’ve built explicitly for the Bayes Rules! book:
Accessibility and Inclusion
We are dedicated to providing a Bayesian resource which is inclusive and accessible. Unfortunately, none of the authors have any formal training in this area. We are continuing to learn on the topic and shared our current efforts with blog posts on https://www.datapedagogy.com/post/bayes-open-access. We have come to the realization that accessibility depends so much on the tools that we use. We wrote this book using R Markdown which does not support alternate text for images. For potential readers who rely on screen readers, our current solution is that we have provided alternate text in the source code. Each alternate text starts with #Alt Text so that it is easier to locate the alternate text. As tools change and we learn more on the topic, we may change the form of alternate texts in the future.
An honest word about installations
We do anticipate some initial barriers to engaging with this resource. Mainly, though rstan is one of the most utilized and powerful Bayesian computing resources, it is not yet universally “easy” to install. The details can vary quite a bit from machine to machine.
Work in Progress
Bayes Rules! is currently a work in progress. The final version of the book will be publicly available for free. In addition, a hard copy of the book will be available for sale by CRC Press. Make sure to bookmark and glimpse at our website occasionally to keep up with the progress www.bayesrulesbook.com.
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.