% \VignetteIndexEntry{Finite mixture models in \textbf{secr}}
% \VignetteKeyword{models}
\documentclass[a4paper]{article}

\title{Finite mixture models in secr}
\author{Murray Efford}
\date{March 3, 2010}

\begin{document}

\maketitle

Variation in detection probability among individuals (`individual
heterogeneity') is a persistent problem in capture--recapture studies.
Ideally, such variation is removed by grouping individuals into
homogeneous classes (males and females) or including continuous
predictors such as body weight. Finite mixture models are an option
when unmodelled heterogeneity remains (Pledger 2000; Borchers and
Efford 2008). The population is assumed to comprise 2 or more latent
classes differing in detection parameters, with an unknown proportion
in each class. The likelihood is a weighted sum over the classes.

\subsection*{Implementation in secr}

Version 1.3 of \textbf{secr} introduced the 2-class finite mixture
model as an option for any `real' detection parameter (e.g., g0 or
sigma of a halfnormal detection function). Consider a simple example,
using conditional likelihood and \texttt{trace = FALSE} for brevity:

<<>>=
library(secr)
data(captdata)
model.0 <- secr.fit(captdata, model = g0~1, CL = TRUE, trace = FALSE)
@

Specify a 2-class mixture by adding the predictor \texttt{h2} to the model formula:
<<>>=
model.h2 <- secr.fit(captdata, model = g0~h2, CL = TRUE, trace = FALSE)
model.h2
@

From the output you can see that \texttt{secr.fit} has expanded the
model to include an extra `real' parameter, \texttt{pmix} for the
proportions in the respective latent classes. You could specify this
yourself as part of the \texttt{model} argument, but \texttt{secr.fit}
knows to add it. There are also two extra `beta' parameters:
\texttt{g0.h22} which is the difference in g0 between the classes on
the link (logit) scale, and \texttt{pmix.h22} which is the proportion
in the second class, also on the logit scale. Fitted (real) parameter
values are reported separately for each mixture class (\texttt{h2 = 1}
and \texttt{h2 = 2}).

We can compare a 2-class finite mixture model to the null (constant)
model using AIC:

<<>>=
AIC (model.0, model.h2)
@

In this case there is no reason to prefer the mixture model.

More complex models are allowed. For example, one might, somewhat
outlandishly, fit a learned response to capture that differs between
two latent classes, while also allowing sigma to differ between
classes:
<<eval=FALSE>>=
model.h2xbh2s <- secr.fit(captdata, model = list(g0~h2*b, sigma~h2), CL = FALSE)
@

\subsection*{Number of classes}

The theory of finite mixture models in capture--recapture (Pledger
2000) allows an indefinite number of classes -- 2, 3 or perhaps
more. Programmatically, the extension to more classes is obvious
(e.g., h3 for a 3-class mixture). The appropriate number of latent
classes may be determined by comparing AIC for the fitted
models\footnote{score tests are not appropriate because the models are
  not nested, at least that's how it seems to me}.

At this time you are advised not to fit more than 2 classes in
\textbf{secr} because there are technical difficulties with the link
function for \texttt{pmix}. This defaults to \texttt{mlogit} (after
the `mlogit' link in MARK), and in fact any attempt to change the link
is ignored.

On the bright side, it is unlikely that you will ever have enough
data to support more than 2 classes. For the data in the example
above, the 2-class and 3-class models have identical log likelihood to
4 decimal places, while the latter requires 2 extra parameters to be
estimated (this is to be expected as the data were simulated from a
null model with no heterogeneity).

\subsection*{Notes}

It's worth mentioning a perennial issue of interpretation: Do the
latent classes have biological reality? The answer is No. Fitting a
finite mixture model does not require or imply that there is a
matching structure in the population (discrete types of animal). A
mixture model is merely a convenient way to capture heterogeneity.

When more than one real parameter is modelled as a mixture, there is
an ambiguity: is the population split once into latent classes common
to all real parameters, or is the population split separately for each
real parameter? The second option would require a distinct level of
the mixing parameter for each real parameter. \textbf{secr} implements
only the 'common classes' option, which saves one parameter.


\subsection*{References}

\noindent Borchers, D. L. and Efford, M. G. (2008) Spatially explicit maximum
likelihood methods for capture--recapture studies. \emph{Biometrics} \textbf{64},
377--385.

\noindent Pledger, S. (2000) Unified maximum likelihood estimates for
closed capture--recapture models using mixtures. \emph{Biometrics} \textbf{56},
434--442.

\end{document}
