Recent advances in spatial modelling of distance sampling surveys

David L Miller
CREEM, University of St Andrews

Royal Statistical Society Highlands Group
University of Aberdeen, Scotland
16 July 2015  # Who is this guy?

• Statistician by training (St Andrews)
• Statistics PhD, University of Bath w. Simon Wood
• Postdoc, University of Rhode Island (Natural Resources)
• Research fellow at CREEM
• Developer of distance sampling software  Ecological questions
How many animals are there?
Where are all the animals?
Why are they there?
Practical question
How can we do this?

(Statistical methods)

(Software)
Density surface models

(Spatial models that account for detectability)

(…and more)

# $$\geq 2$$-stage models Hedley and Buckland (2004). Miller et al (2014).

Detectability

# Distance sampling - line transects Code for animation at https://gist.github.com/dill/2b0c120d5484d338d8ef

# Detection functions

• “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}_i = \frac{1}{w} \int_0^w g(y; \mathbf{z}_i, \boldsymbol{\hat{\theta}}) \text{d}y$

• Horvitz-Thompson-type estimators:

$\hat{N} = \sum_{i=1}^n \frac{s_i}{\hat{p}_i}$

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

# Detection functions # Distance sampling (extensions)

• Extend $$\mathbb{P} \left[ \text{animal detected } \vert \text{ animal at distance } y, \text{ observed covariates}\right] = g(y, \mathbf{z};\boldsymbol{\theta})$$
• Perception bias ($$g(0)<1$$)
• Availability bias
• Detection function formulations
• Measurement error Figure from Marques et al (2007), The Auk

# Mixture model detection functions Data from Daniel Pike, Bjarni Mikkelsen and Gísli Vikingsson. Marine Research Institute, Iceland.

# Mixture model detection functions • Miller and Thomas (2015)
Spatially explicit models

# Data setup Ursus from PhyloPic.

# Two options for response

## $$n_j$$

• raw counts per segment
• model offset is effective area ($$A_j \hat{p}_j$$)

## $$\hat{n}_j$$

• Horvitz-Thompson estimate per segment

$\hat{n}_j = \sum_{i \text{ in segment } j} \frac{s_i}{\hat{p}_i}$

• model offset is then area ($$A_j$$)

# Generalized additive models (in two pages) (I)

If we are modelling counts:

$\mathbb{E}(\hat{n}_j) = A_j\exp \left\{ \beta_0 + \sum_k f_k(z_{jk}) \right\}$

• $$\hat{n}_j$$ has some count distribution (quasi-Poisson, Tweedie, negative binomial, ziP)
• $$A_j$$ is area of segment
• $$f_k$$ are smooth functions (splines $$\Rightarrow f_k(x)=\sum_l \beta_l b_l(x)$$)
• $$f_k$$ can just be fixed effects $$\Rightarrow$$ GLM
• Add-in random effects, correlation structures $$\Rightarrow$$ GAMM
• package dsm
• Wood (2006) is a good intro book

# Generalized additive models (in two pages) (II) Minimise distance between data and model while minimizing:

$\lambda_k \int_\Omega \frac{\partial^2 f_k(z_k)}{\partial z_k^2} \text{ d}z_k$

## “just wiggly enough”

Fitting via REML, see Wood (2011).

# Response distributions

• “Classically”: quasi-Poisson (I’ve not seen data like this)
• Lately: Tweedie, negative binomial
• Exponential family given power parameter
• (mgcv can now estimate power parameters via tw() and nb()) # Autocorrelation

• Can use GEE/GAMM structure for autocorrelation along transects
• $$\text{AR}(p)$$ process (“obvious” structure)
• In general this is unstable
• Random effects are sparse
• Splines are “dense”
• $$\Rightarrow$$ bad for optimisation Case study:

# Case study - black bears in AK

• Area of 26,482 km2 (~33% size of Scotland)
• Double observer surveys using Piper Super Cubs
• 1238, 35km transects, 2001-2003  # 1238 transects # Survey protocol

• Surveys in Spring, bears are there, but not too much foliage
• Generally search uphill
• Double observer (Burt et al, 2014)
• Curtain between pilot and observer; light system
• Go off transect and circle to ID # Black bears

• Truncate at 22m and 450m, leaving 351 groups (out of ~44,000 segments)
• Group size 1-3 (lone bears, sow w. cubs)
• 1402m elevational cutoff       # “Bears don’t like to go too high” # “Bears like to sunbathe” Model selection & checking

# Model selection

• All possible subsets - expensive; stepwise - path dependence
• Term selection by shrinkage to zero effect (Marra & Wood, 2011)
• Approximate $$p$$-values (Marra and Wood, 2012) # Residual checking # Residual checking # Randomised quantile residuals

• Count data is nasty for goodness of fit
• Dunn & Smyth (1996)
• Back transform for exactly Normal residuals
• Fewer problems with artefacts
• dsm::rqgam.check
• (Thanks to Natalie Kelly at CSIRO for the tip)

# rqgam.check # Concurvity

$\text{Altitude} = f(x,y) + \epsilon \quad \text{or} \quad \text{Chlorophyll A} = f(\text{SST}) + \epsilon$

• Not just correlation!
• mgcv::concurvity() computes measures for fitted models Inference

# Abundance estimate for GMU13E

• H-T estimate: ~1500 black bears
• DSM estimate: ~1200 black bears (968 - 1635, CV ~13%)
• Not a huge difference, so why bother?

# Abundance map # Uncertainty propagation

• Uncertainty from detection function AND spatial model (and…)
• Refit model with “extra” term

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

• random effect – fix the corresponding variance matrix $$\boldsymbol{\gamma} \sim N(0,-\mathbf{H}^{-1}_\theta)$$

Williams et al (2011). Bravington, Hedley and Miller (in prep)

# CV map Conclusions

# Conclusion

• Detectability
• Flexible spatial models
• GLMs + random effects + smooths + other extras
• autocorrelation can be modelled
• accounting for uncertainty
• Large, heterogeneous areas
• Spatial component is v. helpful for managers
• Two-stage models can be useful!

# Distance sampling software

• Distance for Windows
• Easy to use Windows software
• Len Thomas, Eric Rexstad, Laura Marshall
• Distance R package
• Simple way to fit detection functions
• Me!
• mrds R package
• More complex analyses - double observer surveys
• Jeff Laake, me

# The dsm package

• Design “inspired by” (“stolen from”) mgcv
• Easy to build simple models, possible to build complex ones
• Syntax example:

model <- dsm(count ~ s(x,k=10) + s(depth,k=6),
detection_function,
segment_data,
observation_data,
family=tw())
• Utility functions: variance estimation, plotting, prediction etc

# Acknowledgements

• St Andrews: Eric Rexstad, Len Thomas, Laura Marshall
• CSIRO: Mark Bravington, Natalie Kelly
• Alaska: Earl Becker, Becky Strauch, Mike Litzen, Dave Filkill

Funding from Alaska Department of Fish and Game  # Thanks!

Slides available at
http://converged.yt/talks/dsm-talk/talk-Aberdeen.html
Appendices

# Appendix - REML Taken from Wood (2011)

# Appendix - Availability

• “Simple correction factor” for diving animals (Winiarski et al 2014)
• Borchers & co have many solutions using Hidden Markov Models

# Appendix - Smoothing in awkward regions Ramsay (2002). Wood, Bravington & Hedley (2008).

# Appendix - Miller and Wood (2014) • Calculate within-area distances
• Use multidimensional scaling to project (high usually)
• Use Duchon splines for smoothing
• Use GCV/REML for dimension selection

# Appendix - Smoothing in less awkward regions • “Remove” troublesome parts of the thin plate spline
• Do this carefully (Fourier transform)
• Nullspace (plane) terms replaced w. low freq

Miller and Kelly (in prep)