Program SPACECAP: software for estimating animal density using spatially explicit capture–recapture models


Correspondence author. E-mail:


  1. The advent of spatially explicit capture–recapture models is changing the way ecologists analyse capture–recapture data. However, the advantages offered by these new models are not fully exploited because they can be difficult to implement.
  2. To address this need, we developed a user-friendly software package, created within the R programming environment, called SPACECAP. This package implements Bayesian spatially explicit hierarchical models to analyse spatial capture–recapture data.
  3. Given that a large number of field biologists prefer software with graphical user interfaces for analysing their data, SPACECAP is particularly useful as a tool to increase the adoption of Bayesian spatially explicit capture–recapture methods in practice.


Capture–recapture (CR) sampling (Otis et al. 1978; Williams et al. 2002) has emerged as a powerful tool for estimating animal abundance by overcoming the key problem of imperfect detection. In such studies ‘capture histories’ of individually identifiable animals (tagged or naturally marked) obtained from repeated sampling across several occasions, typically presented in the ‘1’ (capture) or ‘0’ (no capture) format, comprise the basic data for analysis. As demographic closure is a critical model assumption (Otis et al. 1978; Williams et al. 2002), the survey period is kept short. Data are often analysed using several closed CR models (Amstrup et al. 2005) that incorporate heterogeneity in capture probabilities among individuals, trap response behaviour and time-varying capture probabilities. These analyses are performed using popular user-friendly software programs like CAPTURE (White et al. 1978) and MARK (White & Burnham 1999).

Such analyses incorporate statistical tests to select the best capture–recapture model for the data on hand, estimate capture probabilities, and the population size is estimated based on the assumption that the population is ‘closed’. While these traditional methods provide reliable estimates of abundance, density estimation requires that one also estimates the sampled area. Typically, a buffer area is added around the trap array, based on some empirical, but ad hoc, approaches developed by Wilson & Anderson (1985) and Parmenter et al. (2003). Disadvantages of such approaches to sampled area estimation have been well-recognized statistically (Efford 2004; Efford et al. 2009) and empirically (Soisalo & Cavalcanti 2006; Sharma et al. 2010). Conventional CR analyses suffer from some other key disadvantages and deficiencies in estimating animal density. Foremost among them is the fact that although spatial information in the form of location of capture is available in field studies, the full potential of such critical information related to the animal's home range and movement (and thus to abundance and density) is not meaningfully exploited in conventional CR analyses. Logistical problems, such as inability to adequately cover the entire array with traps without leaving any ‘holes’ (Karanth & Nichols 1998), the frequent need to sample the area in successive ‘blocks’ rather than in a single sweep, irregularly shaped trap arrays that are subsequently treated as circles while estimating variance of density or inclusion of habitats not used by the target species, may all combine and weaken inference under conventional CR analyses.

The recent development of spatially explicit capture–recapture (SECR) models (Efford 2004; Borchers & Efford 2008; Royle et al. 2009a) has addressed several of these problems. Such models have been developed both under a maximum likelihood-based estimation framework (Borchers & Efford 2008) and under a Bayesian framework (Royle & Young 2008; Royleet al. 2009a, b; Gardner et al. 2009). Efford et al. (2009) provide a general review and describe various types of animal ‘captures’ or ‘detections’ that can generate data for such analyses.

In this study, we describe a free software program SPACECAP (Gopalaswamy et al. 2012), implementing a Bayesian SECR analysis of Royle et al. (2009a). Another software program called DENSITY (Efford et al. 2004) is already available and implements the maximum likelihood-based SECR analysis (Borchers & Efford 2008). The ‘SECR’ and the ‘SCRbayes’ in R (R Development Core Team 2009) implement more sophisticated maximum likelihood-based and Bayesian estimators, respectively. However, these R packages do not have Graphical User Interfaces (GUIs).

The reader is referred to the original article by Royle et al. (2009a) for technical details of the models implemented in SPACECAP. Although the models implemented in SPACECAP may suit spatial CR data originating from different types of non-invasive sources of data, such as from camera traps, hair snares or faecal DNA samples, they do not apply to some situations such as kill trapping (Efford et al. 2009).

Our primary motivation here is to enable practising biologists to reliably estimate animal densities using the flexible and powerful Bayesian SECR modelling approach of Royle et al. (2009a) without having to decipher the underlying complexity of the original R code (Royle et al. 2009a, described below), thus meeting a key need of many species conservation initiatives involving rare and elusive animals that can only be studied using non-invasive survey methods (Hatler et al. 2009).

Materials and methods

Package development

SPACECAP was developed within programming environment R (R Development Core Team 2009), and is available within the library of R packages in the Comprehensive R Archive Network (CRAN; We used the Tool Command Language (Tcl) with the Tk graphical user interface toolkit ( to develop its GUI (Fig. 1). The software package includes a detailed Help file that is automatically downloaded with SPACECAP. The software can also be downloaded from the website of US Geological Survey, Patuxent Wildlife Research Center (PWRC) software archive (at

Figure 1.

The Graphic User Interface (GUI) of SPACECAP.

Model description

SPACECAP implements a hierarchical model whereby a state and an observation process are clearly defined. Here, the animal population size and their respective locations constitute the state process. Accordingly, the location of an animal i is defined by math formula. Here math formula, are the individual animal activity centres distributed randomly over some region math formula.

In well-designed CR experiments, investigators maintain a careful record of the individual animal i caught at a specific trap location j on a specific sampling occasion (e.g. a night, or a week) k. Thus, in SPACECAP, binary observations (i.e. 1 s and 0 s) math formula are recorded for an individual animal i caught at trap location j on sample occasion k.

The model is a type of binary regression model, similar to logistic regression, in which, math formula. Here math formula is the probability of detecting an individual i, at trap j on sample occasion k. The probability math formula may be related to covariates of interest by applying a suitable transformation. In SPACECAP, we make use of the complementary log–log link transformation. Thus, the simplest possible model is expressed as

display math

where math formula is a parameter to be estimated. By taking the inverse of the cloglog transformation:

display math

This particular function arises by considering the binary observations to be formally reduced from a Poisson encounter frequency model (see Royle et al. 2009a, for details). That is, math formula is the Pr (that animal i makes at least one encounter with trap j on occasion k) under the Poisson model. The most general model that SPACECAP presently allows is a model in which math formula. In this expression math formula is an indicator of previous capture of individual i in trap j and f is the function that describes the mechanism of decline of detection probability as the distance between trap j and location of individual i increases, that is, a function to make math formula have a half-normal or negative exponential form in SPACECAP. Thus, math formula and math formula are measures of capture probabilities (refer to Royle et al. 2009a, for details) until and after the first capture, respectively. The parameter math formula is a regression coefficient on the effect of distance between individual activity centre math formula and the location of trap j, math formula. math formula is constrained to be <0 implying that the probability of encountering an individual in a trap decreases as the distance between the individual and the trap increases. However, there may be situations where this is not true, for example, when animals spend a lot of time patrolling territory borders (Borchers & Efford 2008).

Models implemented

SPACECAP draws data for analysis in the form of spreadsheet files (such as from Microsoft Excel or OpenOffice) created by the user. The user also defines the specific type of spatial capture–recapture model to be run. Currently, SPACECAP can analyse the Bernoulli encounter process model with the following options (see Royle et al. 2009a, for a discussion):

  1. Spatially explicit OR Non-spatially explicit model.
  2. Behavioural OR Non-behavioural response model.
  3. Half-normal OR Negative exponential detection function model.

The detection function model specifies the mechanism by which the regression coefficient math formula, in the complementary log–log link function, decreases as distance between an animal and a trap increases. Further detail on how the detection function is linked to the observation process is described elsewhere (Borchers & Efford 2008; Royle et al. 2009a).

Parameters reported

In SPACECAP, the parameter math formula or math formula is the population size of individuals – the estimated number of activity centres located in math formula and density is calculated as math formula where math formula is the area of the state-space. Note that math formula is the population size for the prescribed state-space (see Royle et al. 2009a, for a description of the Bayesian estimation procedure) and should not be interpreted as the population size in some sampled area. math formula is the intercept, which is the expected encounter rate of an individual i in trap location j at sampling occasion k, whose activity centre is exactly at the trap location. For a non-behavioural response model, whereby math formula, math formula.

The rate of decline in detection probability as the distance between the animal centre and the trap increases is indicated by the parameter math formula in the complementary log–log link function. SPACECAP reports the parameter math formula. This may also be viewed as a ‘range parameter’ of an animal if the animal movement about its activity centre has a distribution similar to the detection function used. Thus, for a highly mobile animal, this value will tend to be large (e.g. tigers will have a higher σ value compared to civets). We note here that the σ estimated in SPACECAP is scaled according to the standard detection function implemented in the study by Borchers & Efford (2008) and not according to the alternative scaling used in the study by Royle et al. (2009a).

When the ‘behavioural response’ option is chosen, SPACECAP estimates two more derived parameters:

  • math formula is the encounter probability of an individual before initial encounter.
  • math formula is the encounter probability of an individual after initial encounter.

All parameters are estimated using the Markov chain Monte Carlo (MCMC) estimation process using the Metropolis algorithm (Gelman et al. 1996). The current version of SPACECAP only runs one MCMC chain and multiple chains can be analysed by running SPACECAP sequentially. The user is provided with the option of setting the basic MCMC parameters before analysis. These include the number of iterations to be run, the number of iterations to be discarded (called the ‘burn-in period’), thinning rate of the MCMC samples and the data augmentation value (the maximum allowable number of animals possible within the state-space math formula). Precautions must be taken when setting the data augmentation value. If a very low value is set, then there may be a possibility of underestimating the population size by truncating the posterior distribution of the population size estimate. Similarly, if a very high value is set, it may result in high computational time. SPACECAP reports the parameter ψ, which is the fraction of the maximum allowable number (set by the user during data augmentation), that actually represents the true population. We recommend users to set the data augmentation value at about 5–10 times the expected population size in the larger state-space.

Assessment of model adequacy

SPACECAP implements an assessment of model adequacy by computing the Bayesian P-value based on individual encounter frequencies (see Royle et al. 2011, for details on the implementation). In this approach, a fit-statistic, D, is constructed based on individual encounter frequencies, math formula, by using a Freeman-Tukey type statistic (Freeman & Tukey 1950).

display math

where we define math formula to be the encounter frequency for individual i conditional on math formula, math formula is the expected value under the model and θ are the model parameters. A Bayesian P-value estimate close to 0 or 1 would imply model inadequacy. We note that DENSITY utilizes the Akaike's Information Criteria as a means to facilitate model selection.

Summary statistics and output

The approach for parameter estimation in SPACECAP is Bayesian. Therefore, the package produces a summary of parameter estimates comprising of the posterior mean, posterior standard deviation and the 95% highest posterior density intervals (for examples, see Table 1). Thus, for a basic user, SPACECAP provides only all the details relating to the parameter estimates. In addition, SPACECAP also outputs files to allow the user to generate a pixellated map showing fine-scale variation in density (Fig. 2).

Table 1. Posterior density estimates of parameters estimated on tiger data set (Royle et al. 2009a)
ParameterPosterior meanPosterior SD95% Lower HPD level95% Upper HPD level
  1. See Methods and MaterialsParameters reported for definitions of parameters. D is measured per 100 sq km.

σ 1·9750·21661· 58012·412
math formula 0·0160·00340·00960 ·023
ψ 0·43070·08220·27990·5936
math formula 210·6038·915137284
Density D13·032·40798·5388 17·6344

All the prior distributions of parameters defined in SPACECAP are improper uniform priors. So, for all positive parameters, the prior distribution would be Uniform(0,∞) and for all other parameters, the prior distribution would be Uniform(−∞,∞).

Figure 2.

A pixellated density map produced in SPACECAP showing relative animal densities. This map reports estimated tiger densities per pixel of size math formula. White regions represent unsuitable habitat.

Additionally, SPACECAP evaluates the Geweke's diagnostic (Geweke 1992) on the MCMC analysis and provides the user with the z-score of the diagnostic. Values of the z-score statistic of |z−score| > 1·6 implies lack of convergence. Future versions of SPACECAP will permit users to define their own priors and incorporate more model variants.


We report results of a re-analyses of a tiger camera trap data set, originally used in the study by Royle et al. (2009a), using SPACECAP (see Table 1). In Table 2, we compare density estimates using software packages SPACECAP and DENSITY (Efford 2004). We also estimate density using conventional CR approaches implementing the general heterogeneity CR model, math formula-jackknife (Otis et al. 1978), in conjunction with the 1/2 MMDM approach (Wilson & Anderson 1985) for abundance and area estimation, respectively.

Table 2. Comparison of parameter estimates (posterior means and standard deviations) in SPACECAP, DENSITY and math formula-jackknife
Parameter SPACECAP DENSITY math formula-jackknife
  1. See Methods and MaterialsParameters reported for definitions of parameters. The parameter math formula is estimated in DENSITY and is analogous to math formula

σ 1·975 (0·217)1·977 (0·226)NA
math formula 0·016 (0·00)0·015 (0·00)NA
ψ 0·43 (0·08)NANA
math formula 210·60 (38·92)NANA
math formula NA99·69 (19·19)100 (18·15)
math formula 13·03 (2·41)13·23 (2·62)20·3(3·80)

These comparisons show that:

  1. Densities estimated from both the SECR approaches (Bayesian and maximum likelihood) were less than those obtained from conventional CR approaches.
  2. Both Bayesian and maximum likelihood-based inferences from packages SPACECAP and DENSITY, respectively, produced similar estimates of animal density.

The overall conclusion is that as the sample size increases (a combination of number of individuals caught, and their recaptures over multiple locations), there does not appear to be any major difference in density estimates derived using programs SPACECAP or DENSITY. Conventional CR model math formula-jackknife estimates derived from program CAPTURE appear to over-estimate tiger densities if the sampled area is defined using the ad hoc Wilson & Anderson (1985) approach using 1/2 MMDM as buffer. It results in underestimates of densities if the buffer is defined using the Parmenter et al. (2003) full MMDM approach.


In ecological inquiries, the use of Bayesian inference methods (Gelman et al. 1996; Bolker 2008; Royle & Young 2008) is becoming popular because of their inherent capacity to solve complex problems with powerful MCMC algorithms (Tierney 1994), computational power (Venables & Ripley 2002) and flexibility to tailor the modelling to account for particular ecological and sampling situations (e.g. Gardner et al. 2010; Sollmann et al. 2011). We visualize the present and future advantages of the SECR models presented by Royle et al. (2009a) implemented in SPACECAP within this context. Although a typical analysis using SPACECAP now takes much longer than a comparable analysis using DENSITY, we do not view this as a serious practical disadvantage because such analyses are typically performed only once in a season or a year following 45–65 days of field work and several weeks of organizing and checking the data prior to analysis.

We envisage that the modelling framework of Royle et al. (2009a) used in SPACECAP for analysing animal detection data, especially from camera trap surveys, provides the opportunity to incorporate auxiliary information in the form of ‘capture’ data on the same individuals in the form of photographs taken by tourists, animals killed in conflicts or by poachers and even live tracking of animals tagged by radio-frequency identification tags, radio-collars or satellite-collars to improve accuracy and precision of density estimates. The explicit recognition of the fact that most animals have biologically defined home ranges in the statistical modelling allows for a more realistic characterization of the spatial ecology of the constituent individuals within a population. This realistic biological treatment, in turn, is likely to provide more reliable estimates of animal abundance and density. Further, SPACECAP also permits for inference about the locations of uncaught animals of a study, which is not possible with DENSITY, and therefore can be easily extended to modelling demographically open populations. Currently such open model analysis is available with program MARK (White & Burnham 1999) using modelling approaches developed by Jolly (1965); Seber (1965); Pollock et al. (1990); Lebreton et al. (1992); Kendall & Pollock (2001) to derive estimates of critical vital rates such as apparent survival, temporary immigration, transience, recruitment, in addition to the changes in population size and density (see Karanth et al. 2006, for an example of such an analyses with tiger photo-capture data collected over a decade). Recent work by Gardner et al. (2010) has demonstrated the use of SECR approaches to analyse open population models. We hope to incorporate several such developments in SPACECAP during future releases, keeping in view our fundamental goal of making these modern statistical tools available to practitioners. For users, there is a SPACECAP user group email forum where frequently asked questions are answered. Emails to this group can be sent to


We thank Wildlife Conservation Society, NY, Government of India (Department of Science & Technology) and Government of Karnataka (VGST) for funding support. Patuxent Wildlife Research Center, USGS, and Centre for Wildlife Studies provided administrative support. We thank the Clarendon, Jason Hu, WWF-Kathryn Fuller, WCS-Clive Marsh scholarships for supporting the lead author (AMG). Vishal Gokhale, Shreya Dasgupta, Rashmi Bhat, Sumanta Mukherjee, and Deepthi Bharadwaj provided programming assistance. We thank Mohan Delampady for statistical advice. We thank Raghavendra Mogaroy for testing the software on many capture–recapture data sets. We thank Krithi Karanth, two anonymous reviewers and the associate editor for their suggestions to significantly improve this manuscript and the software application.

Disclaimer: Any use of trade, product, or firm names is for descriptive purposes only and does not imply endorsement by the US Government.