Capture-Recapture: Hierarchical Unmarked Abundance Models
Source:vignettes/articles/Nmix.Rmd
Nmix.RmdThis builds on the previous article for unmarked abundance estimates by introducing a new method. It’s presented separately here because, unlike the previous methods that primarily focused on estimating detection probability, this approach accounts for imperfect detection and can model the relationship between abundance and environmental covariates and estimate site-specific abundances. The first approach I’m aware of that really did this, or at least made it more accessible is the N-mixture model developed by Andy Royle (Royle 2004a1). Additionally, it uses repeated counts at the same location (a new detection framework). However, the approach of estimating or modeling abundance at each sampling location can be generalized or used with any of the detection-estimating frameworks we’ve already discussed (Royle 2004b2).
The motivation for the development of N-mixture models came from the
analysis of point-count surveys of birds. Early attempts to estimate
abundance from repeated counts existed prior to N-mixture models, but
none leveraged spatial replicates or performed well in many real-world
situations. Moreover, they typically did not permit estimating the
relationship between covariates and abundance or detection. N-mixture
models were the first to really do both, and their development
ultimately led to the methods that allow us to do the same even when
implementing capture-recapture, removal, or double observer sampling
methods. They are all implemented in the unmarked
package.
The types of studies that typically use N-mixture models are comprised of:
- Surveys performed at multiple sites at roughly the same time
- Multiple visits to each (usually minimum 3; Barker et al. 20173)
This is the first method that uses repeat visits to obtain multiple encounters. The other approaches discussed previously all relied on multiple sites, but only required a single visit. Despite this difference, many of the assumptions required are the same:
- The population is closed at each site, across all visits
- Individuals during a survey at a site are not double counted
- All individuals have the same probability of being observed/ counted
- Repeated counts at a site are independent of one another
The first three are the same as any other sampling protocol for unmarked individuals and why N-mixture methods qualify as a closed-capture method. The last assumption however is new. Practically, this means the counts you make at any visit shouldn’t be affected by your (or another observer’s) previous survey. For example, you cannot take what would otherwise be a removal sampling framework and count all the individuals detected during each time interval. You can perhaps imagine that, any individual detected in an earlier interval has a greater probability of detection in subsequent intervals because you are already aware and keeping track of it (see # 2 above). Those counts are not independent. You really need separate, repeated visits. If you cannot make repeated visits to a site, you are better off using a different method.
The N-mixture model also provides possibly the gentlest framework for introducing mathematical notation common in hierarchical models. It can be useful to understand it to be able to compare and contrast other approaches and often is directly how you might write your own code if you use Bayesian/MCMC methods.
The typical or “canonical” way to write the hierarchical model for an N-mixture model is to write one model for the abundance component and a second model for the detection component:
\begin{equation*} 1.\ \ N_i\sim Poisson(\lambda_i)\\ log(\lambda_i)=\beta_0+\beta_1x_{i1}+\beta_2x_{i2}\ ...\\[0.5cm] 2.\ \ y_{it}\sim Binomial(p_{it},N_i)\\ logit(p_{it})= b_0+ b_1v_{it1}+b_2v_{it2}\ ... \end{equation*}
These first equation shows N_{i} is the unobserved abundance at site i, and it’s just one possible realization or possible value for abundance. This one realization actually comes from a Poisson distribution with a mean of \lambda_i. You can express that average abundance as a function of site-specific covaraites (x_{i1},x_{i2}). This format allows the abundance to vary among sites, based on site-specific covariates.
You might ask, if it’s one site, then why does it come from a Poisson distribution? That’s because in statistics, we may only have one observation (N_i) but we assume that, if we had multiple sites that had exactly the same covariates, we might not get the exact same number of individuals. We would however, expect all those sites to be realizations of the some average (\lambda_i). It’s a bit esoteric, but just know that we assume that anything we observe has some randomness in it. If we didn’t express N_i as coming from a distribution, then there would be no randomness.
The second equation shows the detection process. We make multiple visits, (t) at each site (i). The number of individuals observed (what we actually count) at each site and visit are symbolized by y_{it}. So visits 1-3 at site 1 would look like: y_{1,1}, y_{1,2}, y_{1,3}. Because those counts are not deterministic, we need a distribution. The best choice here is a binomial distribution. It treats our observed counts (y_{it}) as a random draw, where the maximum number of individuals observable at the site is N_i (if detection probability was 1 or perfect), and the probability we observe any individual is p_{it}, the detection probability. Because p_{it} is a probability, you use the logit link to create a linear model with covariates that might explain variation in detection probability among sites and visits. Here, detection probability has covariates v_{it} that differ by site and visit, but you can include ones that only differ by site.
This is the essence of hierarchical models. We have two processes, variation in abundance across sites, and detection across sites and visits that we break apart into sub-models. That may not be the technical way to describe it, but it is practically what is going on. Additionally, this is the framework that lets us estimate the relationship between covariates and abundance at each site, even with other detection methods.
The hierarchical components of N-mixture models are generalizeable (can be combined with) the other detection methods we’ve already covered. There is an additional step involved which you will see. The point right now is to notice almost an “exchangeable parts” aspect to this framework. To show this we will use the example of a removal model with 3 time periods.
To convert the above N-mixture model to one that uses a removal sampling framework, we start with the abundance model.
\begin{equation*} 1.\ \ N_i\sim Poisson(\lambda_i)\\ log(\lambda_i)=\beta_0+\beta_1x_{i1}+\beta_2x_{i2}\ ... \end{equation*}
Nothing changes, the abundance model can remain exactly the same (if needs be). That’s part of the beauty of hierarchical models.
The change in the detection process looks like general removal model counts. Each count y_{it} at site i and removal period t comes from a Binomial process. The total number of individuals available is the number of individuals initially available, N_i, less the number observed in all previous removal periods (\sum_1^{t-1}y_{it}). The probability of removal at time t (\pi_t), also declines. The initial probability an individual is removed in the first period is just p but subsequent removal periods must condition on any individual not being removed beforehand (1-p).
\begin{equation*} 2.\ \ y_{i1}\sim Binomial(\pi_1,N_i)\\[0.25cm] y_{i2}\sim Binomial(\pi_2,N_i-y_{i1})\\[0.25cm] y_{i3}\sim Binomial(\pi_3,N_i-y_{i1}-y_{i2})\\[0.25cm] \left\{ \begin{aligned} & \pi_1=p \\ & \pi_2=p(1-p) \\ & \pi_3=p(1-p)(1-p)\\ \end{aligned} \right. \end{equation*}
This is meant to demonstrate, conceptually, the ability to change
detection models without changing the underlying abundance model. The
actual code or math that unmarked uses or you will use on
NIMBLE or JAGS will be different, but that has
more to do with computational issues. You can also adjust the abundance
model, to a zero-inflated, negative binomial or something else, however
you see fit.
This flexibility afforded by hierarchical models does come with some limits. Just because you can conceptually define your hierarchical model, doesn’t mean it will work like you expect. There are many problems or limitations that you may run into based on choices you make, from how you write the model to what software you use to estimate parameters.
- Bayesian MCMC algorithms can be picky about how you actually write
the code for something like
JAGSorNIMBLE.- The equations we used to represent the detection or observation
process of a removal model won’t actually work in
JAGS. There are alternative ways to express the detection process that do work. It is entirely related to how MCMC algorithms work because the same expression can work just fine when using maximum likelihood tools to estimate parameters.
- The equations we used to represent the detection or observation
process of a removal model won’t actually work in
- The
unmarkedpackage uses maximum likelihood methods which can work in circumstances that MCMC fails, but:- You can’t fit random effects.
- You sacrifice flexibility and are tied to using models and distributions the package creators provide.
In addition to the above computational issues, there are more general problems that often come up, and are very frequently ignored. That issue is parameter identifiability. It comes in two flavors:
Structural Identifiability:
More common in physical capture-recapture models, but still possible here. It means that because of how you wrote the model, some parameters only ever appear in combination with others, making each individual component impossible to distinguish from another. Importantly, this form of identifiability issue cannot be fixed by collecting more data. It is structural. You need to reconsider the model being used to fix it.
General Identifiability issues:
This is more common when you have limited data, low detection probabilities, low abundance, or you are trying to fit some form of zero-inflated abundance model (for unmarked abundance type-problems (Kéry 2018)4, or include far too many covariates. This is a more pernicious issue, because, unlike structural issues, the model itself can be a-OK, with the right kind of data. The problem only appears under certain circumstances, such as you, collecting data for your thesis.
It arises because there are multiple potential values either abundance or detection could take on that gives you your observed data. For example,if you surveyed a site and only made two visits, and got counts of 3 and 2, that could mean the true abundance could be 5 with a detection probability of 0.5, or a true abundance of 10 with detection probability ~0.2. More visits to more sites and variation in abundance among visits that can be explained by some good covariates is what allows the computer to figure out which set of detection/abundance values is correct. When counts are low, either because abundance is low or detection is low (<0.3), you are more likely to have parameters that are unidentifiable. When you add in a lot of covariates, you can also end up with identifiability issues.
Detecting and dealing with unidentifiable parameters
Once you collect your data, there isn’t a lot you can do to prevent having identifiability issues. In an ideal would you might find some literature that might give you some approximate values for abundance and detection while designing your project. If either of those are small, you might rethink using a hierarchical model or at least prepare for more sampling effort.
But if you have data already how can you tell if you have identifiability issues? If you are using MCMC, one indicator will be posterior chains with slow mixing, which yields very low effective sample sizes to the number of posterior samples. If using MLE, you are more likely to get an error message about parameters not being uniquely estimated, or a message about convergence. Both are indicators of identifiability issues (but not uniquely). If using MCMC methods, you can look at correlation among parameters, but from different parts of the model. We kind of expect some correlation among the covariate parameters for abundance or among detection, but if the posterior chains of an abundance parameter and detection parameter exhibit correlation >0.3, it could indicate their is an identifiability issue. The best way to test for parameter identifiability is to use data cloning.
Data Cloning
Data cloning is straightforward conceptually. You literally “clone” your data a certain number of times and re-estimate the parameters. You just make n copies of the data and treat all n copies as if it was one data set. What you want to compare is the standard error (SE) of all the parameters from the original data set (one copy) to the SE of the parameters of the cloned data set. The SE of the cloned data set parameters should be:
SE_{cloned}= \frac{1}{\sqrt{n}} \cdot SE_{original}\\ OR\\ \frac{SE_{original}}{SE_{cloned}} = \sqrt{n}
For example, if I made 25 copies of my data, I expect SE_{original} to be 5 times as large as the SE for the cloned parameter. If what you see is not close to that quantity (maybe \pm 0.1 in this example) then that means the parameter is not identifiable.
Simplify the model
So if you’ve found that you have unidentifiable parameters, what can you do? You can’t report the results of unidentifiable parameters, because they don’t mean anything, there is no real interpretation. The only option left is to change the model.
You may find that fitting a less complex model (fewer covariates) works. You can make the detection probability on average, the same among visits at all sites, reduce the number of random effects you include, etc. Otherwise, you may need to fit a simple GLM to your data and model “relative abundance”.
While there are still some assumptions when using a GLM, some very smart statisticians have shown that, at least for some types of hierarchical abundance models, using relative abundance and log-linear model can be effective for determining the relationship between covariates and relative abundance (Barker et al. 2017). You still account for imperfect detection by including covaraites related to detection. More generally, those smart folks point out that even for N-mixture models, the estimate of abundance produced is still an index and probably not true abundance. You cannot easily derive an estimate of abundance like you can with an N-mixture model, but if it’s still an index, perhaps you ought not to?
Regardless, changing to a GLM might not be what you had in mind, but it is a viable alternative when you just can’t fit a hierarchical model.