Loading [MathJax]/jax/output/CommonHTML/jax.js
+ - 0:00:00
Notes for current slide
Notes for next slide

Teaching Bayesian modeling with
Bayes Rules!

bit.ly/isba-rules

Talk at International Society for Bayesian Analysis World Meeting

Mine Dogucu, Ph.D. 
University of California Irvine

2022-07-01

1

We have reviewed curricula of 152 high ranking universities and colleges in the United States and identified 51 Bayesian courses at the undergraduate level.

We have examined prerequisites, majors, and course content through catalog and syllabus analysis.

Dogucu, M., & Hu, J. (2022). The Current State of Undergraduate Bayesian Education and Recommendations for the Future. The American Statistician.

3

Southern California Data Science Program

HDR DSC awards: #2123366 #2123380 #2123384

NSF logo

Through this collaborative grant between University of California Irvine, California State University Fullerton, and Cypress College, a Bayesian course will be adopted at California State University Fullerton.

6

A headshot of a woman with long blonde hair wearing a brownish yellow tshirt and a red and pink floral silk scarf wrapped around her neck.

Alicia Johnson
Macalester College

A headshot of a man with short dark hair, and a dark moustache. He is wearing a blue button up shirt and dark gray jacket

Miles Ott
Twitter

8

Bayesian Foundations

  • Bayes' Rule
  • The Beta-Binomial Bayesian Model
  • Balance and Sequentiality in Bayesian Analysis
  • Conjugate Families

three curves on a single plot with no axis labeled. It is coloring scheme indicates its similarity to the previous plot with prior, scaled likelihood and posterior

Posterior Simulation & Analysis

A traceplot with no axis labels. Traceplots have thin vertical lines with varying lengths.

  • Grid Approximation

  • The Metropolis-Hastings Algorithm

  • Posterior Estimation

  • Posterior Hypothesis Testing

  • Posterior Prediction

Regression and Classification

A scatterplot with multiple regression lines passing through points. These regression lines are not all over the place, they are clustered with similar but varyin intercepts and slopes.

  • Normal Regression
  • Poisson and Negative Binomial Regression
  • Logistic Regression
  • Naive Bayes Classification

Hierarchical Models

a figure showing hierarchy with a rectangle on top. With a set of arrows pointing downwards leading to a set of rectangles below which also have a set of arrows pointing downwards leading to a different set of rectangles.

  • Normal hierarchical models without predictors
  • Normal hierarchical models with predictors
  • Non-Normal Hierarchical Regression & Classification
9

Background of students taking the course

  • Prerequisite: STATS 120C. Introduction to Probability and Statistics III
  • Recommended: STATS 110. Statistical Methods for Data Analysis I
  • Students: Data Science major (required), Statistics minor (elective)
10

Big Picture

11

Context

In Alison Bechdel’s 1985 comic strip The Rule, a character states that they only see a movie if it satisfies the following three rules (Bechdel 1986):

  • the movie has to have at least two women in it;
  • these two women talk to each other; and
  • they talk about something besides a man.
12

Context

In Alison Bechdel’s 1985 comic strip The Rule, a character states that they only see a movie if it satisfies the following three rules (Bechdel 1986):

  • the movie has to have at least two women in it;
  • these two women talk to each other; and
  • they talk about something besides a man.

Let π, a random value between 0 and 1, denote the unknown proportion of movies that pass the Bechdel test (i.e. π[0,1]).

13

14

  • Feminist thinks that women are not represented in movies often.
  • Clueless is unsure.
  • Optimist thinks that Bechdel is a low bar for representation of women in movies and thinks almost all movies pass the test.
  • Can you match the plots with the personas?
15

Plotting Beta Prior with bayesrules package

One can use the plot_beta() function in the bayesrules package to try different shape parameters. Example:

library(bayesrules)
plot_beta(alpha = 2, beta = 10)

16

Plotting Beta Prior

17

18
one_mh_iteration <- function(w, current){
# STEP 1: Propose the next chain location
proposal <- runif(1, min = current - w, max = current + w)
# STEP 2: Decide whether or not to go there
proposal_plaus <- dnorm(proposal, 0, 1) * dnorm(6.25, proposal, 0.75)
current_plaus <- dnorm(current, 0, 1) * dnorm(6.25, current, 0.75)
alpha <- min(1, proposal_plaus / current_plaus)
next_stop <- sample(c(proposal, current),
size = 1, prob = c(alpha, 1-alpha))
# Return the results
return(data.frame(proposal, alpha, next_stop))
}
19
mh_tour <- function(N, w){
# 1. Start the chain at location 3
current <- 3
# 2. Initialize the simulation
mu <- rep(0, N)
# 3. Simulate N Markov chain stops
for(i in 1:N){
# Simulate one iteration
sim <- one_mh_iteration(w = w, current = current)
# Record next location
mu[i] <- sim$next_stop
# Reset the current location
current <- sim$next_stop
}
# 4. Return the chain locations
return(data.frame(iteration = c(1:N), mu))
}
20
set.seed(84735)
mh_simulation_1 <- mh_tour(N = 5000, w = 1)

21

library(rstan)

# STEP 1: DEFINE the model
stan_bike_model <- "
data {
int<lower=0> n;
vector[n] Y;
vector[n] X;
}
parameters {
real beta0;
real beta1;
real<lower=0> sigma;
}
model {
Y ~ normal(beta0 + beta1 * X, sigma);
}
"
# STEP 2: SIMULATE the posterior
stan_bike_sim <-
stan(model_code = stan_bike_model,
data = list(n = nrow(bikes),
Y = bikes$rides, X = bikes$temp_feel),
chains = 4, iter = 5000*2, seed = 84735)
22

library(rstanarm)

bike_model <- stan_glm(rides ~ temp_feel, data = bikes,
family = gaussian,
prior_intercept = normal(5000, 1000),
prior = normal(100, 40),
prior_aux = exponential(0.0008),
chains = 4, iter = 5000*2, seed = 84735)
23

library(bayesplot)

mcmc_trace(bike_model, size = 0.1)

mcmc_dens_overlay(bike_model)

24

Pedagogical Approach

25

Learning Bayesian Modeling is Fun

How can we live if we don’t change? —Beyoncé. Lyric from “Satellites.”

vs.

What is probability?

26

Checking Intuition

There are two ellipses at the top of the image. The first ellipse reads 'Prior: Only 40% of articles are fake'. The second ellipse reads 'Data: Exclamation points are more common among fake news'. There are two arrows each from the upper two ellipses leading to a third ellipse in the lower part of the image. The third ellipse reads 'Posterior: Is the article fake or not?'

27

Active Learning

Hands-on Programming

Metropolis-Hastings Algorithm

An icon of a student sitting on a chair and in front a desk with a computer typing.

28

Compute for a single case, then use built-in functions

predictions <- rstanarm::posterior_predict(bike_model, newdata = bikes)
bayesplot::ppc_intervals(bikes$rides, yrep = predictions,
x = bikes$temp_feel, prob = 0.5, prob_outer = 0.95)

29
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow