Internals: Derivatives

Here we give expressions for the derivatives of the detection function likelihood. This document provides some analytic results that improve computation time.

Computations were performed using Wolfram Mathematica 10. The workbook used for the computations may be downloaded here.


In general the likelihood is of the following form for line transects:

\[L_{y|z} = \prod_{i=1}^n f(y_i,z,\theta) = \prod_{i=1}^n \frac{g(y_i,z,\theta)}{\int_\text{left}^\text{right} g(y,z,\theta) dy}\]

Naturally, we think about this on the log scale:

\[\log\left( L_{y|z} \right) = l_{y|z} = \sum_{i=1}^n \log \left( \frac{g(y_i,z,\mathbf{\theta})}{\int_\text{left}^\text{right} g(y,z,\mathbf{\theta}) dy} \right)\]

Half-normal detection function

\[g(x,z,\theta) = \exp\left(-\frac{x^2}{2 \sigma^2} \right)\]

Note to define the error function in R, use:

erf <- function(x) 2 * pnorm(x * sqrt(2)) - 1


\[\int_0^\text{right} 1- \exp\left[ -\left(\frac{x}{\sigma}\right)^{-b} \right] dx = \text{right}-\frac{\sigma \Gamma \left(-\frac{1}{b},\left(\frac{\sigma }{\text{right}}\right)^b\right)}{b}\]


From Becker and Quang (2009),

\[\int_0^\text{left} g(x,h,r,\lambda) dx = h\lambda \mathbb{P}\left[X \leq \frac{w}{b \lambda}\right]\]

where $X \sim \Gamma(r,1)$ and

\[b = \frac{1}{\Gamma(r)} \left( \frac{r-1}{e}\right)^{r-1}\]

$r>1$ is the shape parameter of the gamma (to be estimated) and $0 < h \leq 1$.


Becker, EF, and PX Quang. A Gamma-Shaped Detection Function for Line-Transect Surveys with Mark-Recapture and Covariate Data. Journal of Agricultural, Biological, and Environmental Statistics 14(2) (2009): 207–23.