A simple Bayesian occupancy model for two interacting species with R and jags

We begin by simulating survey data for two commensal species for the following scenario. Species 1 has a 50% probability occupancy. Species 2 benefits from the presence of species 1, so its probability of occupancy is 83% when species 1 is also present, but only 50% in the absence of species 1. One hundred sites are surveyed 10 times each. The probability of detection for both species is 0.3.

data_generator_commensal_species = function(psi, p, nSites, nReps){ # occupancy prob psi, detection prob p
 # true occupancy state
 z1 <- rbinom(nSites, 1, psi)
 z2 <- rbinom(nSites, 1, psi + z1/3)
 # sampling of true occupancy state
 y1 <- matrix(NA, nSites, nReps)
 y2 <- matrix(NA, nSites, nReps)
 for(i in 1:nSites) {
 y1[i,] <- rbinom(nReps, 1, z1[i]*p) # detection history for species 1
 y2[i,] <- rbinom(nReps, 1, z2[i]*p) # "" species 2
y = data_generator_commensal_species(psi = .5, p = .3, nSites = 100, nReps = 10)

We specify the model structure in jags.

model {
## Priors
a0 ~ dunif(-5, 5)
b0 ~ dunif(-5, 5)
b1 ~ dunif(-5, 5)
p ~ dunif(0, 1)

## Model
# State process
for(i in 1:nSites) {
 logit(psi1[i]) <- a0
 logit(psi2[i]) <- b0 + b1 * Z1[i]
 Z1[i] ~ dbern(psi1[i])
 Z2[i] ~ dbern(psi2[i])
# Detection process
 for(j in 1:nOccs) {
   y1[i, j] ~ dbin(p, Z1[i])
   y2[i, j] ~ dbin(p, Z2[i])

Then we run the model with R and jags.

d = list( y1 = y[[1]], y2 = y[[2]], nSites = 100, nOccs = 10)
mod = jags.model("commensal_multispecies.txt", d)
post = coda.samples(mod, c("a0", "b0", "b1", "p"),1e4)

Here are the posterior distributions. A nice fit to the scenario for the simulated data.

Pika featured on NatGeo

Our research was featured on the Years of Living Dangerously series on the National Geographic Channel. Here I am with the pika and Aasif Mandvi.


Erratum: When I interact with the media I do my best to convey the research accurately and hope for the best from the editing process. Here are a few small erratum/clarifications from this scene:

  • The scene cuts from me mentioning pika short calls, to me imitating long calls, then to pika footage from Colorado.
  • It is indeed legal to hunt pikas in some places such as Alaska. To my knowledge this practice is rare. Hunting is not an appreciable contributor to pika declines.
  • I misspoke somewhat when I said, “in Yosemite more than half of the small mammals they looked at were disappearing from low elevation sites.” I should have said “more than half of the small mammals they looked at were shifting their distribution upslope.” Moritz et al 2008 found that 57% of species (16/28) they looked at shifted their distribution upslope significantly (p < 0.05) either through lower elevation range contraction or upslope range expansion.

Have we been underestimating the Earth’s sensitivity to GHGs?

Recent studies suggest that science may have underestimated the climate’s sensitivity to greenhouse gasses. Armour 2016 discusses upward-adjustments in historical-era estimates of temperature sensitivity to account for the location of ocean surface temperature measurements, different types of climate-forcings, and time-delayed response. Friedrich et al 2016 found that the Earth’s climate-sensitivity over the past 784,000 years was greater than what the current (CMIP5) suite of climate models would suggest. Critical questions remain in how quickly the climate responds to forcing.

Paleo-Climate Sensativity

Paleoclimatic estimates of climate-sensitivity over the Pleistocene suggest that the current suite of CMIP5 models may underestimate the climate’s sensitivity. Figure from Friedrich et al 2016. Shown is RCP8.5 emission scenario.

Dispatch from the field: catching leopard lizards in a mega-drought

Joe McLeod, Gambelia

Master lizard catcher Joe McLeod catches a blunt-nosed leopard lizard at its burrow entrance. Photo by Eliot Schoenig.

As part of research to support the conservation of blunt-nosed leopard lizards, starting in 2014, we resumed a capture-mark-recapture study on the Elkhorn Plain. The study plots were worked previously for 17 years by Dave Germano and ESRP.

One of the effects of drought we’ve found—in the mark-recapture data and in geographically extensive surveys—is that when precipitation levels are below a threshold the lizards fail to reproduce. That’s what we found in 2014 on the Elkhorn Plain: drought caused complete reproductive failure. Read more about the recruitment patterns we found here.

Gambelia sila

Leopard lizard under an Ephedra shrub. Photo by Elliot Schoenig.

Joseph Stewart holding Gambelia sila.

Me posing with two leopard lizards. Photo by Taylor Noble.