/BayesCMR_workshop

JAGS/R scripts and reading materials for the Bayesian Capture-Recapture workshop at the 2017 SMM Conference, Halifax NS

Primary LanguageR

Bayesian Capture-Recapture in JAGS: Workshop for SMM 2017 Biennial Conference

Welcome to the SMM2017 workshop on Bayesian Capture-recapture. This page contains materials from the full-day workshop, including

  • 8 lectures and tutorials
  • R and JAGS code

The focus of the workshop was to introduce JAGS for Bayesian Capture-Mark-Recapture (including models CJS, POPAN, PCRD, MSCRD as a more general type of Hidden Markov Model). The underlying idea is based on the paper of Rankin and Nicholson et al. 2016 and Rankin's 2017 Ph.D. thesis. Researchers may find the lectures and R/JAGS code useful to make their own CJS, POPAN, PCRD, and MSCRD models in JAGS.

Feel free to submit feature requests and report issues in the Github issue tracker page (see link above)

Data A special thanks to those researchers who let us their odontocetes capture-recapture data-set for some of the practical exercises, including Dr. Tim Hunt (Humpback dolphins, POPAN, Part 6), Krista Nicholson (Bottlenose dolphins, PCRD, Part 7), and Dr. Daniele Cagnazzi (Humpback dolphins, MSCRD, Part 8, unpublished). These data-sets are detailed in their respective publications: Hunt et al, Nicholson et al, and unpublished data from Cagnazzi (but see his Doctoral Thesis).

OUTLINE

Outline

PART 1: Bayesian Inference: History, Philosophy, and Properties

A brief introduction to Bayesianism. What is posterior inference? What divides subjective vs objective Bayesians? How do sample-size and prior information influence the frequency properties of a Bayes estimator? What is sample-based approximation? PDF presentation here. No R/JAGS code

PART 2: Priors and Probabilities

This was a simple exercise for participants to study some common probability distributions available in JAGS. A PDF lecture is here. A few helpful R functions are available here.

PART 3: JAGS

This part included 3 exercises to familiarize participants with the JAGS syntax and R workflow. The emphasis in on i) encoding prior beliefs and ii) encoding the likelihood (joint probability distribution of the data), together which serve as the basic skeleton for all subsequent JAGS models. There are three JAGS exercises in the R file as part of this section:

  • a simple Bernoulli model for average annual survival of 30 dolphins (with Beta Priors)
  • a Bernoulli model for average annual survival of 30 dolphins (with logit-Normal priors)
  • a logistic-regression of average annual survival of 30 dolphins (with logit-Normal priors)

See the notes at the end of the PDF from Part 1.

PART 4: Hidden Markov Models, a Unifying Framework for CMR

This tutorial shows how the CJS, POPAN, PCRD, and MSCRD are just variants of a more general Hidden-Markov Model. Participants learn about how to specify transmission matrices and emission matrices in the JAGS syntax as well as the rationale behind the latent state markov process and the complete data likelihood to recast a variety of CMR models as HMMs.

  1. exercise 1 is to run a simple HMM (like a POPAN model) for a single capture-history, then
  2. exercise 2 generalizes the HMM for multiple capture histories and time-varying parameters, then
  3. exercise 3 adds POPAN-like derivatives to the JAGS script (Super-population, population abundance births, and probability of entry)

See the lecture PDF and the PDF describing the tutorials. The R code is in PART 4 directory.

Key concepts and techniques:

  • HMM transmission and emission matrices
  • latent states and the latent Markov process
  • complete data likelihood

PART 5: Cormack-Jolly-Seber as a HMM

This tutorial introduces the idea of conditioning on the first capture and re-casts the CJS model as a very simple HMM. Capture recapture data is from Nicholson et al. Also discussed are the Horvitz-Thompson estimator of abundance, as well as using the linear-model specification to include individual and temporal covariates in capture-probabilities (e.g., for individual heterogeneity, sex, and effort information)

See the lecture PDF and R/JAGS tutorial files especially the file R_cjs.R.

Key concepts and techniques:

  • first-capture vs full-capture models
  • Horvitz-Thompson abundance estimation
  • linear models for CMR parameters
  • sex and effort as covariates

PART 6: POPAN and Model-Selection

This section revisits the simple three-state POPAN model, using data from Hunt et al. Part 1 of the lecture (popan.pdf) discusses POPAN in detail, whereas Part 2 of the lecture (popan2.pdf) addresses Bayesian model selection according to two philosophical positions: predictive criteria (such the WAIC) versus the prequentialist/Bayes Factor approach. See the R file R_popan.R.

Key concepts and techniques:

  • parameter-expansion and data-augmentation
  • pseudo-individuals
  • derivatives (population abundance, births, etc.)
  • Watanabe-Akaike Information Criterion (WAIC) for minimizing a predictive loss
  • The marginal likelihood and Bayes Factors for finding the highest posterior model

PART 7: Pollock's Closed Robust Design, and Hierarchical Bayes

This tutorial introduces the Kendall model for temporary emigration and the Pollock's Closed Robust Design. See the lecture PDF and R/JAGS tutorial files, especially the file called R_pcrd.R.

Key concepts and techniques:

  • secondary periods and population-closure
  • nested for loops
  • Hierarchical Bayes and random-effects
  • hyperpriors and shrinkage

PART 8: Multistrata Close Robust Design

This section showcases an actual JAGS working script from a current study using the MSCRD to model a population of Humpback dolphins in Australia. The key-point is that, although seemingly complex, this model has basically the same structure as all the previous models (transmission and emission matrices, etc.). See the R file R_example_mscrd_cagn.R.

INSTALLATION

Participants should first:

  • install JAGS
  • then the R package rjags > install.packages("rjags").
  • check that your installation was successful. Please navigate to the test_script directory and run the file R_test_JAGS_script.R (NOTE: windows users please use the WINDOWS version). If successful, the script should make a plot with title "Success!"

The workshop is based heavily on the publication: Rankin RW, Nicholson K, Allen SJ, Krützen M, Bejder L, Pollock KH. 2016. A full-capture Hierarchical Bayesian model of Pollock's Closed Robust Design and application to dolphins. Frontiers in Marine Science 3:25, doi: 10.3389/fmars.2016.00025.

Sincerely, \ Robert W. Rankin, Dr. \ Krista E Nicholson, Ph.D Candidate