Preface

Why this book?

The HMM framework has gained much attention in the ecological literature over the last decade, and has been suggested as a general modelling framework for the demography of plant and animal populations. HMMs are increasingly used to analyse capture-recapture data and estimate key population parameters (e.g., survival, dispersal, or recruitment) with applications in all fields of ecology. The first objective of this book is to illustrate the flexibility of HMM to decompose complex problems in smaller pieces that are easier to understand, model and analyse.

In parallel, Bayesian statistics is well established and fast growing in ecology and related disciplines, because it resonates with the scientific reasoning and allows accommodating uncertainty smoothly. The popularity of Bayesian statistics also comes from the availability of free pieces of software (WinBUGS, OpenBUGS, JAGS, Stan) that allow practitioners to code their own analyses. The second objective of this book is to illustrate the use of the R package NIMBLE (de Valpine et al. (2017)) to analyse capture-recapture data with HMM in a Bayesian framework. NIMBLE is seen by many as the future of Bayesian statistical ecology to deal with complex models and/or big data.

An important part of the book consists in case studies from published papers presented in a tutorial style to abide by the “learning by doing” philosophy. The third objective of this book is to provide reproducible analyses with code and data to teach yourself by example.

Who should read this book?

This book is aimed at beginners who’re comfortable using R and write basic code, as well as connoisseurs of capture-recapture who’d like to tap into the power of the Bayesian side of statistics. For both audiences, thinking in the HMM framework will help you in confidently building models and make the most of your capture-recapture data.

What will you learn?

The book is divided into three parts. The first part Foundations is aimed at getting you up-to-speed with Bayesian statistics, NIMBLE, and hidden Markov models. The second part Transitions will teach you all about capture-recapture models for open populations, with reproducible R code to ease the learning process. The third part Case studies provides real-world case studies from the scientific literature that you can reproduce using material covered in previous chapters. These problems can either i) be used to cement and deepen your understanding of methods and models, ii) be adapted for your own purpose, or iii) serve as teaching projects. Here say that the code is available on GitHub, and the data through a package crdata.

What won’t you learn?

I won’t lie, there is some maths in this book. However, the equations I use are either simple enough to be understood without a background in maths, or can be skipped without prejudice. I do not cover Bayesian statistics or even hidden Markov models exhaustively, I provide just what you need to work with capture-recapture data. If you are interested in knowing more about these topics, hopefully the section Suggested reading at the end of each chapter will put you in the right direction. There are also a number of important topics specific to capture-recapture that I do not cover, including closed-population capture-recapture models (Williams, Nichols, and Conroy 2002), spatial capture-recapture models (Royle et al. 2013) and continuous models (Rushing 2023) (I might end up writing a chapter on continuous models.). These models can be treated as HMMs, but for now the usual formulation is just fine. These developments will be the subject of new chapters in a second edition, hopefully.

Prerequisites

This book uses primarily the R package NIMBLE, so you need to install at least R and NIMBLE. A bunch of other R packages are used. You can install them all at once by running:

install.packages(c(
  "bookdown", "coda", "forecast", "ggtern", "gtools", 
  "here", "janitor", "magick", "MCMCvis", "nimble", 
  "nimbleEcology", "patchwork", "pdftools", 
  "RColorBrewer", "sessioninfo", "tidyverse", 
  "wesanderson" 
))

How this book was written

I wrote this book in RStudio http://www.rstudio.com/ide/ using bookdown http://bookdown.org/. The book website https://oliviergimenez.github.io/banana-book is hosted with GitHub Pages https://pages.github.com/, and automatically updated after every push by Github Actions https://github.com/features/actions. The source is available from GitHub https://github.com/oliviergimenez/banana-book.

The version of the book you’re reading was built with R version 4.2.3 (2023-03-15) and the following packages:

package version source
bookdown 0.33 CRAN (R 4.2.0)
coda 0.19-4 CRAN (R 4.2.0)
forecast 8.21 CRAN (R 4.2.0)
ggtern 3.4.1 CRAN (R 4.2.0)
gtools 3.9.4 CRAN (R 4.2.0)
here 1.0.1 CRAN (R 4.2.0)
janitor 2.2.0 CRAN (R 4.2.0)
magick 2.7.4 CRAN (R 4.2.0)
MCMCvis 0.15.5 CRAN (R 4.2.0)
nimble 1.0.1 CRAN (R 4.2.0)
nimbleEcology 0.4.1 CRAN (R 4.2.0)
patchwork 1.1.2 CRAN (R 4.2.0)
pdftools 3.3.3 CRAN (R 4.2.0)
RColorBrewer 1.1-3 CRAN (R 4.2.0)
sessioninfo 1.2.2 CRAN (R 4.2.0)
tidyverse 2.0.0 CRAN (R 4.2.0)
wesanderson 0.3.6 CRAN (R 4.2.0)

About the author

My name is Olivier Gimenez (https://oliviergimenez.github.io/). I am a senior (euphemism for not so young anymore) scientist at the National Centre for Scientific Research (CNRS; https://www.cnrs.fr/en) in the beautiful city of Montpellier, France.

I struggled studying maths, obtained a PhD in applied statistics a long time ago in a galaxy of wine and cheese. I was awarded my habilitation (https://en.wikipedia.org/wiki/Habilitation) in ecology and evolution so that I could stop pretending to understand what my colleagues were talking about. More recently I embarked in sociology studies because hey, why not.

Lost somewhere at the interface of animal ecology, statistical modeling and social sciences, my so-called expertise lies in population dynamics and species distribution modeling to address questions in ecology and conservation biology about the impact of human activities and the management of carnivores. I would be nothing without the students and colleagues who are kind enough to bear with me.

You may find me on Twitter/X (https://twitter.com/oaggimenez), GitHub (https://github.com/oliviergimenez), or get in touch by email at olivier|dot|gimenez|at|cefe|dot|cnrs|dot|fr.

Acknowledgements

Writing a book is quite an adventure, and a lot of people contributed to make this book a reality. I wish to thank:

  • Rob Calver, Sherry Thomas, Vaishali Singh and Kumar Shashi at Chapman and Hall/CRC.
  • Marc Kéry, Rachel McCrea, Byron Morgan and Etienne Prévost for their positive reviews of the book proposal I sent to Chapman and Hall/CRC, and their constructive comments and suggestions.
  • Marc Kéry for his precious pieces of advice on the process of writing.
  • Perry de Valpine, Daniel Turek, Chris Paciorek and Ben Goldstein for the NIMBLE and nimbleEcology R packages.
  • Colleagues who shared their data; See list at https://github.com/oliviergimenez/banana-book#readme
  • People who commented, corrected, offered pieces of advice; See list at https://github.com/oliviergimenez/banana-book#readme.
  • Yihui Xie for the bookdown R package.
  • Attendees of the workshops we run in relation to the content of this book (latest edition was in 2023, see https://oliviergimenez.github.io/bayesian-hmm-cr-workshop-valencia/)
  • Perry de Valpine, Sarah Cubaynes, Chloé Nater, Maud Quéroué and Daniel Turek for their help with running workshops in relation to the content of this book (2021 edition: https://oliviergimenez.github.io/bayesian-cr-workshop/; 2022 edition: https://oliviergimenez.github.io/hmm-cr-nimble-isec2022-workshop/).
  • Ruth King, Steve Brooks and Byron Morgan for the workshop on Bayesian statistics for ecologists we taught in Cambridge, the book we wrote together (King et al. 2009), and their contribution to statistical ecology.
  • Jean-Dominique Lebreton, Roger Pradel and Rémi Choquet for the workshops on modelling individual histories with state uncertainty we taught over the years, and sharing their science of capture-recapture with me.
  • My family, including my mother, my parents-in-law for their kindness and hospitality, my amazing kids and wonderful wife for putting up with me while I was writing this book.