# Internals: Fitting MRDS models

# Purpose

This document outlines how to fit mark-recapture distance sampling models. In particular we are interested in fitting the mark-recapture part of the model. We assume for the prupose of these instructions that the detection function component is fitted separately.

# Models

MRDS methods are concerned with estimating the probability of detection at zero distance ($g(0)$). MRDS models come in many different flavours, three implemented “modes” are (Laake and Borchers, 2004, Section 6.3.3):

`"io"`

: observers act independently, setting up “trials” for each other; detection functions are estimated for each observer.`"rem"`

: observers are aware of each others’ detections. Once an observer has seen an animal, it is “removed” for the other.`"trial"`

: observer 2 sets up trials for observer 1. Only the detection function for observer 1 is estimated.

Even if observers are acting independently, their observations can be dependent due to unmodelled heterogeneity in detection probability. Each of these comes in an “full” and “point” independence version. When full independence is assumed, observers detections are independent at all distances, for “point” independence, the assumption only holds at zero distance.

Here we don’t think about the independence levels, we are just interested in estimating $\mathcal{L}_\omega$.

# Fitting - IO models

We wish to model: \(p_{ij} = \mathbb{P}(\text{animal } i \text{ detected by observer } j)\) But using the methods given in Buckland et al (1993) we can use a GLM to model: \(\pi_{ij} = \mathbb{P}(\text{animal } i \text{ detected by observer } j \quad\vert \text{ detected by at least one observer})\\ = \frac{p_{ij}}{1-\prod_{j=1}^2 (1-p_{ij})}.\) And since alegbra yields: \(\log \frac{\pi_{ij}}{1-\pi_{ij}} = \log \frac{p_{ij}}{1-p_{ij}} - \log p_{ij^\prime},\) where $j^\prime=3-j$ (the observer which is not $j$), we can therefore model the $\pi_{ij}$s using logistic regression with an offset of $-\log p_{ij^\prime}$, re-fitting until convergence of the parameters. Note that the $ij$ subscript doesn’t refer to matrix elements, rather to the $i^\text{th}$ observeration, and observer identifier $j$ – effectively it’s a “flat” ID.

## Algorithm

An algorithm for this:

- Let the offsets, $A_{ij}=0$.
- While parameter values have not converged:
1. Fit logistic regression: $\text{detected}
*{ij} = A*{ij} + X_{ij}\boldsymbol{\beta}$ . 2. Calculate $A_{ij}=-\log p_{ij^\prime}$. - Calculate the $p_{ij}$.

# R code

Simple R code for this (assuming that `egdata`

contrains the covariates `detected`

, `distance`

and `observer`

):

```
# setup
max.iter <- 1000
oldpar<-c(0,0)
newpar<-c(100,100)
off.set <- rep(0,nrow(egdata))
iter<-1
while(max(abs(newpar-oldpar)/oldpar)>1e-8 & iter <max.iter){
# important to switch around the offsets, jprime stuff
egdata$offset[egdata$observer==1] <- off.set[egdata$observer==2]
egdata$offset[egdata$observer==2] <- off.set[egdata$observer==1]
# fit the model again
gg <- glm(detected~distance+offset(off.set),family=binomial(link="logit"),
offset=offset,data=egdata)
# reset parameters
oldpar<-newpar
newpar <- as.vector(coef(gg))
# calculate the pis
pis <- predict(gg)
# obtain the offset for the next model
off.set <- -log(plogis(pis - off.set))
iter <- iter + 1
}
```

# Estimates of detectability

See Prediction for information on how to obtain estimates of detectability.

# References

- Buckland, S T, J L Laake, and D L Borchers. “Double-Observer Line Transect Methods: Levels of Independence.” Biometrics 66, no. 1 (2010): 169–77.
- Borchers, DL, JL Laake, C Southwell, and CGM Paxton. “Accommodating Unmodeled Heterogeneity in Double-Observer Distance Sampling Surveys.” Biometrics 62, no. 2 (2006): 372–78. doi:10.1111/j.1541-0420.2005.00493.x
- Buckland, ST, JM Breiwick, KL Cattanach, and JL Laake. “Estimated Population Size of the California Gray Whale.” Marine Mammal Science 9, no. 3 (1993): 235–49.
- Laake, JL, J Calambokidis, SD Osmek, and DJ Rugh. “Probability of Detecting Harbor Porpoise From Aerial Surveys: Estimating G (0).” Journal of Wildlife Management, 1997, 63–75.
- Laake, JL, and DL Borchers. “Methods for Incomplete Detection at Zero Distance.” In Advanced Distance Sampling, edited by ST Buckland, DR Anderson, KP Burnham, JL Laake, DL Borchers, and L Thomas, 48–70, Oxford University Press, 2004.
- Laake, JL, BA Collier, ML Morrison, and RN Wilkins. “Point-Based Mark-Recapture Distance Sampling.” Journal of Agricultural, Biological, and Environmental Statistics 16, no. 3 (2011): 389–408.
- Laake, JL, DL Borchers, L Thomas, DL Miller and J Bishop (2014).
`mrds`

: Mark-Recapture Distance Sampling (mrds). R package version 2.1.10.