Accounting for detectability in spatially-explicit abundance models of cetaceans

David L Miller (@millerdl)

University of Bergen – 12 September 2017

Who is this guy?

  • Currently:
    • “Honorary” research fellow at St Andrews
  • Previously:
    • CSIRO Marine Laboratory (close-kin)
    • NOAA North East Fisheries Science Centre
    • Centre for Research into Ecological and Environmental Modelling, St Andrews
    • University of Rhode Island
    • PhD Uni. Bath, UK; GAMs etc w/ Simon Wood
not a real statistician,
not a real ecologist,
knows nothing about whales.

with that in mind...

(a talk)

Abundance and distribution: why?

  • Want to know where they are
    • whale watching/stock assessments
  • Want to know where they aren't
    • Navy/seismic/oil/shipping/fishing etc
  • Want to know what they like/dislike
    • ecology/biology

How? Big white boats

How? Big white boats

Can't we just count them all?

Detectability

Why do birds
Suddenly appear
Every time you are near?
Most likely
It is simply
perception bias.
Aaaaah ah ah ah ah ah ah aah
Perception bias



@PaulAllor

Distribution

Example data in this talk

Sperm whales off the US east coast

Example data

Let's talk about detectability

Detectability

Distance sampling

  • “Fit to the histogram”
  • Model:

\[ \mathbb{P} \left[ \text{animal detected } \vert \text{ animal at distance } y\right] = g(y;\boldsymbol{\theta}) \]

  • Calculate the average probability of detection:

\[ \hat{p} = \frac{1}{w} \int_0^w g(y; \boldsymbol{\hat{\theta}}) \text{d}y \]

Distance sampling (extensions)

  • Covariates that affect detectability (Marques et al, 2007)
  • Perception bias (\( g(0)<1 \)) (Burt et al, 2014)
  • Availability bias (Borchers et al, 2013)
  • Detection function formulations (Miller and Thomas, 2015)
  • Measurement error (Marques, 2004)  

Figure from Marques et al (2007)

Horvitz-Thompson-like estimators

  • Rescale the (flat) density and extrapolate

\[ \hat{N} = \frac{\text{study area}}{\text{survey area}}\sum_{i=1}^n \frac{s_i}{\hat{p}_i} \]

(where \( s_i \) are group/cluster sizes)

  • Assume flat density
  • Stratify?

That's not really how the ocean works...

Density surface models

Hedley and Buckland (2004)

Miller et al. (2013)

DSM process flow diagram

How do we model that?

SPOILER ALERT: your model is probably just a very fancy GLM

Generalised additive models (in 1 slide)

Taking the previous example…

\[ \mathbb{E}\left(n_j\right) = \color{red}{A_j}\color{blue}{\hat{p}_j} \color{green}{\exp}\left[\color{grey}{ \beta_0 + \sum_k s_k(z_{kj})} \right] \]

\( n_j\sim \) some count distribution

  • \( \color{red}{\text{area of segment}} \)
  • \( \color{blue}{\text{probability of detection in segment}} \)
  • \( \color{green}{\text{(inverse) link function}} \)
  • \( \color{grey}{\text{model terms}} \)

What about those s thingys?

Covariates

  • space, time, environmental (remotely sensed) data

plot of chunk unnamed-chunk-1plot of chunk unnamed-chunk-1

plot of chunk seconddsm

How do we build them?

plot of chunk unnamed-chunk-2

  • Functions made of other, simpler functions
  • Basis functions \( b_k \), estimate \( \beta_k \)
  • \( s(x) = \sum_{k=1}^K \beta_k b_k(x) \)

Straight lines vs. interpolation

plot of chunk wiggles

  • Want a line that is “close” to all the data
  • Don't want interpolation – we know there is “error”
  • Balance between interpolation and generality

Making wigglyness matter

  • Fit needs to be penalised
  • Something like:

\[ \int_\mathbb{R} \left( \frac{\partial^2 s(x)}{\partial x^2}\right)^2 \text{d}x\\ \]

  • (Can always re-write this in the form \( \mathbf{\beta}^T \mathbf{S} \mathbf{\beta} \))
  • Estimate the \( \beta_k \) terms but penalise objective
    • “closeness to data” + penalty (REML?)

Smoothing parameter

plot of chunk wiggles-plot

How wiggly are things?

  • We can set basis complexity or “size” (\( k \))
    • Maximum wigglyness
  • Smooths have effective degrees of freedom (EDF)
  • EDF < \( k \)
  • Set \( k \) “large enough”

Beyond univariate smooths?

plot of chunk tensor

  • Can build tensor product terms
  • Take 2 or more univariate terms
  • Can be computationally expensive!

Thin plate (regression) splines

  • Isotropic (rotation-invariant) smoothers
  • Radial basis + global polynomial terms \[ f(x,y) = \sum_{i=1}^n \delta_i \eta(r_i) + \sum_{j=1}^3 \alpha_j \phi_j(x,y) \]
  • \( n \) = # data \( \Rightarrow \) too many parameters!
  • eigen-decompose model matrix (\( X = UDU^\text{T} \)) & truncate

Smoothing in awkward regions

Biologists rarely work on the unit square (or even \( \mathbb{R}^2 \)).

Miller and Wood (2014)

  • Calculate within-area distances
  • Use multidimensional scaling to project (high usually)
  • Use Duchon splines for smoothing
  • Use REML for dimension selection

Smoothing in less awkward regions

\[ \int \int_{\mathbb{R}^2} \lvert \boldsymbol{\tau} \rvert \left\{ \left ( \mathfrak{F} \frac{\partial f}{\partial x} \left(\boldsymbol{\tau} \right) \right )^2 + \left (\mathfrak{F} \frac{\partial f}{\partial y}\left(\boldsymbol{\tau} \right) \right )^2 \right\} \text{d}\boldsymbol{\tau}. \]

Let's fit a model

library(dsm)
dsm_env_tw <- dsm(count~s(Depth) + s(NPP) + s(SST),
                  ddf.obj=df_hr,
                  segment.data=segs, observation.data=obs,
                  family=tw())

dsm is based on mgcv by Simon Wood

Tobler's first law of geography

“Everything is related to everything else, but near things are more related than distant things”

Tobler (1970)

Implications of Tobler's law

plot of chunk pairrrrs

Fitting models using robust criteria

  • GCV performs poorly in presence of concurvity
  • (GCV has a less well defined minimum in general)
  • REstricted Maxmimum Likelihood or Marginal Likelihood preferred (Wood, 2011)


Smooth term selection

  • (approximate) \( p \)-values (Marra & Wood, 2012)
    • Bayesian uncertainty has good frequentist properties
  • extra penalty or shrinkage of nullspace (Marra & Wood, 2011)

plot of chunk shrinkie-plot

Double-penalty shrinkage

\[ \mathbf{S}_j = \mathbf{U}_j\mathbf{\Lambda}_j\mathbf{U}_j^{T} \]

\( \mathbf{\Lambda}_j \) contains 0s due to basis nullspace

Form: \[ \mathbf{S}_j^{*} = \mathbf{U}_j^{*}\mathbf{U}_j^{*T} \]

Fit a GAM with two penalties:

\[ \lambda_j \mathbf{\beta}^T \mathbf{S}_j \mathbf{\beta} + \lambda_j^{*} \mathbf{\beta}^T \mathbf{S}_j^{*} \mathbf{\beta} \]

(In practice, add select = TRUE)

Empirical Bayes...?

  • Penalty is a prior precision matrix
  • but it's improper as it's not full rank
  • Extra shrinkage makes priors proper!
  • Shrinkage: assume nullspace should be shrunk less than the wiggly part
  • Double penalty: no assumption as to how much to shrink the null space

\( \Rightarrow \) fit GAMs using general MCMC software (jags, greta etc)

Inference

Predictions over arbitrary areas

plot of chunk predplot

  • Don't want to be restricted in where to predict
    • Predict within survey area
    • Extrapolate outside (with caution)
  • Working on a grid of cells

Okay, but we're actually doing statistics...

Bootstraps are a bad idea

  • Bootstraps for splines (random effects) bad idea
  • Where there is no effort, resamples underestimate uncertainty
  • Use distributional results \( \boldsymbol{\beta}\vert \mathbf{y}, \boldsymbol{\lambda} \sim N(\boldsymbol{\hat{\beta}}, \mathbf{V}_\boldsymbol{\beta}) \)

Variance propagation

  • 2-stage model! Need to propagate uncertainty!
  • Refit model with “extra” term

\[ n_j = A_j p_j \exp \left\{ \color{red}{\left[\frac{ \partial \log p_j(\boldsymbol{\theta})}{\partial\boldsymbol{\theta}} \Big\vert_{\boldsymbol{\theta} = \hat{\boldsymbol{\theta}}}\right] \boldsymbol{\gamma}} + \beta_0 + \sum_k f_k(z_{jk}) \right\} \]

  • random effect – fix the corresponding covariance matrix \( \boldsymbol{\gamma} \sim N(0,-\mathbf{H}^{-1}_\theta) \)
  • Bravington, Hedley & Miller (in prep)

Plotting uncertainty

plot of chunk vars

  • Maps of coefficient of variation (probably biased?)
  • CV for given stratum (better)
  • This is hard

Communicating uncertainty

  • Are animations a good way to do this?
  • Simulate from posterior parameter distribution
  • \( \boldsymbol{\beta}\vert \mathbf{y}, \boldsymbol{\lambda} \sim N(\boldsymbol{\hat{\beta}}, \mathbf{V}_\boldsymbol{\beta}) \)- Some features (e.g. shelf, N-S gradient) stick out

Availability

We can only see whales at the surface

  • What proportion of the time are they there?
    • Acoustics
    • Tags (DTAGs etc)
    • Behavioural studies
  • Fixed correction to \( \hat{p} \)?
  • Model via fancy Markov models (Borchers et al, 2013)

Picture from University of St Andrews Library Special Collections

I am going to stop talking very soon

2 (or more)-stage models

  • Not “cool” but…
  • Multi-stage models are handy!
  • Understand and check each part
  • Split your modelling efforts amongst people

Conclusions

  • This methodology is general
    • Bears, birds, beer cans, Loch Ness monsters…
  • Models are flexible!
    • Linear things, smooth things, random effect things (and more)
  • If you know GLMs, you can get started with GAMs/DSMs
    • Mature theoretical basis, still lots to do
  • Active user community, active software development

Acknowledgements

  • St Andrews: Eric Rexstad, Len Thomas, Louise Burt, Laura Marshall, Steve Buckland, Sharon Hedley
  • Duke: Jason Roberts, Laura Mannocci
  • CSIRO: Mark Bravington
  • Australian Antarctic Division: Natalie Kelly
  • Funding: University of St Andrews, State of Rhode Island, US Navy, NOAA, International Whaling Commission

Resources

Thanks!

Slides w/ references available at converged.yt

References

Borchers, D. L., Zucchini, W., Heide-Jørgensen, M. P., Cañadas, A., Langrock, R., Buckland, S. T., & Marques, T. A. (2013). Using hidden Markov models to deal with availability bias on line transect surveys. Biometrics, 69(3).
Burt, M. L., Borchers, D. L., Jenkins, K. J., & Marques, T. A. (2014). Using mark-recapture distance sampling methods on line transect surveys. Methods in Ecology and Evolution, 5(11).
Dunn, P. K., & Smyth, G. K. (1996). Randomized Quantile Residuals. Journal of Computational and Graphical Statistics, 5(3).
Hedley, S. L., & Buckland, S. T. (2004). Spatial models for line transect sampling. Journal of Agricultural, Biological, and Environmental Statistics, 9(2).
Marques, T. A. (2004). Predicting and correcting bias caused by measurement error in line transect sampling using multiplicative error models. Biometrics, 60(3).
Marques, T. A., Thomas, L., Fancy, S. G., & Buckland, S. T. (2007). Improving estimates of bird density using multiple-covariate distance sampling. The Auk, 124(4).
Marra, G., & Wood, S. N. (2011). Practical variable selection for generalized additive models. Computational Statistics and Data Analysis, 55(7).
Marra, G., & Wood, S. N. (2012). Coverage Properties of Confidence Intervals for Generalized Additive Model Components. Scandinavian Journal of Statistics, 39(1).
Miller, D. L., Burt, M. L., Rexstad, E. A., & Thomas, L. (2013). Spatial models for distance sampling data: recent developments and future directions. Methods in Ecology and Evolution, 4(11).
Miller, D. L., & Thomas, L. (2015). Mixture models for distance sampling detection functions. PLoS ONE.

Handy awkward question answers

Don't throw away your residuals!

gam.check

plot of chunk unnamed-chunk-3

rqgam.check (Dunn and Smyth, 1996)

plot of chunk unnamed-chunk-4

Wigglyness by derivatives

Animation of derivatives

Penalty matrix

  • For each \( b_k \) calculate the penalty
  • Penalty is a function of \( \beta \)
    • \( \lambda \beta^\text{T}S\beta \)
  • \( S \) calculated once
  • smoothing parameter (\( \lambda \)) dictates influence

Count distributions

plot of chunk countshist

  • Response is a count (not not always integer)
  • Often, it's mostly zero (that's complicated)
  • Want response distribution that deals with that
  • Flexible mean-variance relationship

Negative binomial

plot of chunk negbin

  • \( \text{Var}\left(\text{count}\right) = \) \( \mathbb{E}(\text{count}) + \kappa \mathbb{E}(\text{count})^2 \)
  • Estimate \( \kappa \)
  • Is quadratic relationship a “strong” assumption?
  • Similar to Poisson: \( \text{Var}\left(\text{count}\right) =\mathbb{E}(\text{count}) \)

Tweedie distribution

plot of chunk tweedie

  • \( \text{Var}\left(\text{count}\right) = \phi\mathbb{E}(\text{count})^q \)
  • Common distributions are sub-cases:
    • \( q=1 \Rightarrow \) Poisson
    • \( q=2 \Rightarrow \) Gamma
    • \( q=3 \Rightarrow \) Normal
  • We are interested in \( 1 < q < 2 \)
  • (here \( q = 1.2, 1.3, \ldots, 1.9 \))