# Bayes Rules! An Introduction to Bayesian Modeling with R

*2021-06-18*

# Preface

*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.

## 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.
*But wait*!
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.
Further, 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.

## 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 the

**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", "tidybayes", "broom.mixed", "modelr"), dependencies = TRUE)`

Install the

**bayesrules**package which contains some data sets and functions we’ve built explicitly for the*Bayes Rules!*book:`::install_github("bayes-rules/bayesrules") devtools`

Several of the datasets in this package have been subset from larger sources, using non-random methods to obtain subsets that match our pedagogical goals. These potentially biased datasets should

*not*be used for rigorous research purposes. Should this be your goal, please see the relevant data help file to identify the original, complete data source.

## Accessibility and inclusion

We are dedicated to providing an inclusive and accessible Bayesian resource. We are continuing to learn, and shared our current efforts at https://www.datapedagogy.com/posts/2020-07-24a-bayes-open-access. All the figures in the online version book are supported by alternate text and should be able accessible to visually-impaired readers with a screen-reader. We continue to improve the alternate texts of figures as we learn more on writing better alternate text.

**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 will be freely available online.
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.

## License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.