Setting expectations and meeting our data

Bayesian workshop - STEP 2023

Scott James Perry

University of Alberta

By the end of this workshop you will be able to…


  • explain how Bayes is different
  • set reasonable priors for your models
  • fit, interpret, visualize, and report the three most common models

\(rt \sim Normal(\mu,\sigma)\)

\(\mu \sim Normal(0,3)\) \(\sigma \sim Exponential(1)\)


You may not…


  • feel confident adopting this approach right away
  • be ready to fit all models you currently use



Should I always go Bayesian?


You may want to think twice about going Bayesian if you have:

  • a simple model
  • lots of data
  • little prior information



To start your Bayesian journey, I will:


  • create a safe space (questions are critical)
  • foster comprehension of fundamental aspects
  • emphasize creating a reasonable prior model
  • touch on all aspects of the Bayesian workflow


“Over Hill - Bilbo and Gandalf” by Joel Lee

Attendee experience


  • Balancing content: I’ll be checking in and adjusting

Attendee experience


  • Balancing content: I’ll be checking in and adjusting


  • This stuff is hard: a burning sensation in your brain is normal

Workshop structure: we alternate between theory and practice


  1. Intro: Bayes and brms
  2. Simple models and how they fit
  3. Contrast coding and prior simulation
  4. Lognormal likelihood and LOOIC
  5. Logistic regression and ROPEs
  6. Hierarchical models

Let’s meet our data - lexical decision


  • One data-set with only native listeners
  • Second data-set with native and non-native listeners


Dependent variables


rt (reaction time):

  • How long from stimulus onset to button press
  • recorded in milliseconds
  • positive real number


acc (accuracy):

  • Whether the response was correct (1) or incorrect (0)
  • binary variable

Independent variable - lexical frequency


log_Freq:

  • unigram frequency (log-transformed)
  • continuous variable ranging from 1 to 5


scaled_Freq:

  • standardized version of log_Freq

Independent variable - listener group


  • group_factor: factor w/ two-levels (L1 & L2)
  • group_sumcoded: sum-coded version (L1 = -0.5, L2 = 0.5)

Let’s take a second and load our data


In the course folder (STEP_2023_Bayes) you have a folder called data with the following files:

  • LD.Rda and LD.csv
  • LD_L2.Rda and LD_L2.csv

You can use the load() function for .Rda files and read.csv() files for .csv files as you’d prefer, I will be using the .Rda files

# Load the LD data-set using the .Rda file
load("data/LD.Rda")

# Using the .csv file
LD <- read.csv("data/LD.csv")

Now for some EDA to break the ice



  • Load the data (see script S1_E1_data_loading.R)
  • Explore the data
  • Check in and ask any questions