Go beyond OLS!
An introduction to Poisson, Beta, and zero-inflated Beta Bayesian distributional regression
While ordinary least squares (OLS) regression is an important method for modeling relationships, it’s not always well-suited for outcome variables that are proportions (bounded between 0–100%) and counts (limited to whole numbers). In this workshop, you’ll learn how to use Bayesian regression techniques to get richer and more detailed information from more specialized types of data. Using R, Stan, {brms}, and {marginaleffects} you’ll learn how to (1) correctly model counts and proportions and (2) process, plot, interpret, and communicate the results.
Workshop presented at the Département de science politique at the Université de Montréal
Materials
All the materials we’ll use today are in a self-contained RStudio project that you can download to your computer. It is a .zip
file, so make sure you extract/unzip it after downloading it (especially if you’re using Windows!)
Alternatively, you can open this project in your browser without needing to install or download anything on your computer. HOWEVER, the Posit server isn’t powerful enough to run the Bayesian models—it will crash unless you increase the amount of RAM or CPUs on the server. Open this Posit.cloud project (you’ll need to create a free account really quick):
Packages
You’ll need all these packages on your computer:
install.packages(
c("tidyverse", "marginaleffects", "brms", "tidybayes", "ggdist", "tinytable",
"patchwork", "scales", "ggridges", "ragg", "knitr", "rmarkdown", "glue",
"here", "extraDistr", "betareg", "parameters", "broom", "distributional",
"palmerpenguins", "bayesrules", "countrycode", "WDI"
) )
Plan for today
This is a hands-on workshop. There are no slides and we’ll do minimal formal stats or math. Instead, we’ll work through several Quarto documents and do a bunch of live-coding together.
Here’s what we’ll do:
- Distributions
- OLS as distributional regression
- Poisson regression
- Beta regression
- Zero/one-inflated Beta regression
You can access all these using the top navigation bar too. I’ve also included a page with links to other resources and examples.