A screen-reader-friendly transcript of the lecture slides: all slide text, tables, figure descriptions, and speaker notes.
About these notes
Each section is one slide. Figures carry text descriptions where available. For the concepts with worked examples, also read the plain-language summary and lab for this session.
Slide 1
Introduction to Bayesian Analysis Part Deux
Figure 1.1. 3D surface plot of a bivariate normal probability density over axes x1 and x2, showing a bell-shaped peak (~0.15) at the origin, with a semi-transparent horizontal reference plane.
Many slides adapted from Matt Falcy ODFW, and SESYNC course by Chris Che-Castaldo, Mary B. Collins, N. Thompson Hobbs (with permission)
Figure 1.2. Portrait of Thomas Bayes with Bayes' theorem overlaid. Equation: P(A|B) = P(B|A) P(A) / P(B).
Slide 2: Where to go from here
Figure 2.1. Book cover: 'Statistical Rethinking: A Bayesian Course with Examples in R and Stan,' Second Edition, by Richard McElreath.Figure 2.2. Screenshot of two YouTube playlists by Richard McElreath: Statistical Rethinking 2023 (20 videos) and 2022 (21 videos), with a woodpecker thumbnail.
Slide 3: Where to go from here
Figure 3.1. Book cover: 'The Theoretical Biologist's Toolbox: Quantitative Methods for Ecology and Evolutionary Biology' by Marc Mangel.
If you have strong quantitative skills and want to become a master
Covers a diverse array of topics
Figure 3.2. Book cover: 'The Ecological Detective: Confronting Models with Data' by Ray Hilborn and Marc Mangel, Monographs in Population Biology 28.
Slide 4: This course is just a jumping off point
Train yourself by reading books.
Consider pursuing side project using methods you want to learn
Consider attending weekly math/stats seminars
Figure 4.1. Book cover: 'The Ecological Detective: Confronting Models with Data' by Ray Hilborn and Marc Mangel, Monographs in Population Biology 28.Figure 4.2. Book cover: 'Ecological Models and Data in R' by Benjamin M. Bolker, showing a fish on coral.Figure 4.3. Book cover: 'The Theoretical Biologist's Toolbox: Quantitative Methods for Ecology and Evolutionary Biology' by Marc Mangel.Figure 4.4. Book cover: 'Applied Hierarchical Modeling in Ecology' Volume 1, by Marc Kery and J. Andrew Royle, with a green dragonfly.Figure 4.5. Book cover: 'Applied Hierarchical Modeling in Ecology' Volume 2, Dynamic and Advanced Models, by Marc Kery and J. Andrew Royle, with a red dragonfly.Figure 4.6. Book cover: 'Bayesian Models: A Statistical Primer for Ecologists' by N. Thompson Hobbs and Mevin B. Hooten.
Figure 6.1. Slide titled 'Nonlinear regression'; the embedded figure did not render, only a citation to Bolker 2008, Ecological Models and Data in R.
Unlike with lm() and glm()
this easily extends to nonlinear functional forms
(e.g. Spawner-Recruit Lab)
Slide 7
Spawner-Recruit Lab
Another Example with Derived Quantities
Spawner-recruit problem. We want to estimate
equilibrium number of spawners without harvest, Neq
Spawners that maximize sustained yield
The MSY harvest
Figure 7.1. Scatterplot of Recruits versus Spawners with a curved black Beverton-Holt fit that saturates near 4000-4500 recruits, and a blue 1:1 replacement line.
Neq
Smsy
Hmsy
Figure 7.2. R code for derived quantities: Neq <- b*(a-1)/a; Smsy <- b*sqrt(1/a) - b/a; Hmsy <- 1 - sqrt(1/a).
Beverton-Holt Model
R = (a*S)/(1+a/b*S)
How would you estimate these with uncertainty in frequentist framework?
Slide 8
Figure 8.1. Table 'You don't have to be normal!' mapping data types to distribution, mean function, and link: continuous/normal (identity), discrete-positive/Poisson (log), 0-or-1/Bernoulli (logit), [0,1]/beta (logit), positive/lognormal and gamma (log).
Multilevel models (also known as hierarchical linear models, linear mixed-effect model, mixed models, nested data models, random coefficient, random-effects models, random parameter models, or split-plot designs)
Hierarchical models are very natural in a Bayesian framework
Slide 12
Figure 12.1. Slide text: Clark 2003 modeled fecundity of spotted owls and its implications for population growth; data were offspring counts per pair of owls, sample size n=197.
Slide 13
Figure 13.1. Directed graph with arrows from alpha and beta pointing to lambda_i. Equation: [lambda,alpha,beta|y] proportional to product Poisson(y_i|lambda_i) gamma(lambda_i|alpha,beta) times gamma(alpha|.001,.001) gamma(beta|.001,.001).
Gamma is the conjugate prior and flexible/non-negative. Good choice here
These are called hyperpriors.
What is going on here? Is this possible in glmer()
#offspring per pair of owls
Model offspring counts with Poisson, but each individual’s rate parameter drawn from a Gamma distribution.
Not just variance in counts, but variance within owl pair and among owl pairs!
Slide 14
Figure 14.1. Directed graph with arrows from alpha and beta pointing to lambda_i. Equation: [lambda,alpha,beta|y] proportional to product Poisson(y_i|lambda_i) gamma(lambda_i|alpha,beta) times gamma(alpha|.001,.001) gamma(beta|.001,.001).
Gamma is the conjugate prior and flexible/non-negative. Good choice here
These are called hyperpriors.
What is going on here?
This model is hierarchical.
Individual fecundity comes from data from that individual and is informed by entire population
Every individual has one of these
But they arise from a common distribution
Slide 15
MULTILEVEL MODELING
Soil nitrous-oxide emissions are measured at multiple sites across the world. Each site has multiple measurements of (nitrogen input, emission). Different sites have wildly different soil organic carbon, climate, and microbial communities — so we expect site-level structure.
Build complexity incrementally!
We will fit no pooling, complete pooling, andrandom intercept model, before adding more complexity
Slide 16
Complete pooling
Figure 16.1. JAGS complete-pooling model code: single alpha and beta priors, sigma, and one likelihood loop regressing log.emission on centered log nitrogen input, plus a loop deriving predicted emissions.
Iterate likelihood over the data
Only one alpha and beta
Only one alpha and beta
Slide 17
No pooling
Figure 17.1. JAGS no-pooling model code: a separate alpha[j] prior for each of n.sites, shared beta and sigma; likelihood uses alpha[group[i]], with nested loops for site-level predicted emissions.
Every site gets its own alpha
Every site gets its own alpha
“group” was passed as data
Slide 18
Random intercept
Partial pooling
Figure 18.1. Directed acyclic graph for a partial-pooling random-intercept model: y_ij depends on beta, alpha_j, sigma, and covariate x_ij; alpha_j depends on hyperparameters mu_alpha and varsigma_alpha.Figure 18.2. JAGS partial-pooling model code: hyperpriors mu.alpha and sigma.alpha, site intercepts alpha[j] drawn from dnorm(mu.alpha, tau.alpha), shared beta/sigma, likelihood, and predicted emissions loops.
Alpha varies by site but within shared distribution
Slide 19
Random intercept
Partial pooling, but also attempt to EXPLAIN site-level differences
Figure 19.1. JAGS model code adding a site-level carbon covariate: mu.alpha[j] <- kappa + eta*w[j] and alpha[j] ~ dnorm(mu.alpha[j], tau.alpha), explaining variation in intercepts among sites, plus predicted emissions.
Every site gets its own alpha
Figure 19.2. Directed acyclic graph: y_ij depends on alpha_j, beta, sigma, and covariate x_ij; alpha_j depends on kappa, eta, varsigma_alpha, and site covariate w_j feeds into alpha_j.
In the previous example, we assumed that the variation in the intercept was attributable to spatial variation among sites. We did not try to explain that variation, we simply acknowledged that it exists. Now we are going to “model a parameter” using soil carbon content data at the site-level to explain variation in the intercepts among sites.
Alpha varies by site but within shared distribution
Flexibility! Intercepts can depend on soil carbon
Slide 20
Latent Variable Modeling I - Occupancy
Figure 20.1. Tree diagram of occupancy detection: surveying an area leads to not seeing the species (y=0), which means either absent (z=0) or present but undetected (z=1); or seeing it (y=1), meaning present (z=1).
“Latent variable” inferred rather than observed
What should the priors be?
yi | zi ~ Bernoulli(pi · zi)
zi ~ Bernoulli(ψi)
logit(pi) = α0 + α1 · covariate1
logit(ψi) = β0 + β1 · covariate1
Slide 21
Figure 21.1. Slide 'Choosing reasonable flat priors on logit intercept.' Four panels: a normal(0, var=10000) prior on logit(p) gives a U-shaped bathtub distribution of p (mass at 0 and 1), while normal(0, var=2.7) gives a roughly uniform p.
An implied Uniform(0,1) prior for ψ is a Logistic distribution prior for intercept centered at 0 with scale parameter 1
Logistic(μ = 0, σ = 1)
Slide 22
DYNAMIC OCCUPANCY MODELING LAB
Figure 22.1. Diagram of dynamic occupancy transitions from year t-1 to year t between states z=0 (absent) and z=1 (present), with rates: colonization gamma, persistence phi, and complements 1-gamma and 1-phi.
Slide 23
N-mixture Models
Separating Process and Observation Error
Imperfect detection is also a problem when estimating abundance
N-mixture models can account for imperfect detection of individuals within a species
What should the prior distributions be?
How should we link these variables to environmental covariates?
Figure 23.1 — needs description This slide contains an image not yet described in text. Instructor: add a description.