## Summary

Camera traps are an essential tool to quantify the distribution, abundance and behavior of mobile species. As detection probabilities vary greatly among camera trap locations, they must be accounted for when analyzing such data, which is generally done using occupancy models.

We introduces a Bayesian Time-dependent Occupancy Model for Camera Trap data (

`Tomcat`), suited to estimate relative event densities in space and time.`Tomcat`allows to learn about the environmental requirements and daily activity patterns of species while accounting for imperfect detection. It further implements a sparse model that deals well will a large number of potentially highly correlated environmental variables.By integrating both spatial and temporal information, we extend the notation of overlap coefficient between species to time and space to study niche partitioning.

We illustrate the power of

`Tomcat`through an application to camera trap data of eight sympatrically occurring duiker species in the the savanna – rainforest ecotone in the Central African Republic and show that most species pairs show little overlap. Exceptions are those for which one species is very rare, likely as a result of direct competition.

## 1. Introduction

Camera traps have become an essential part of many wildlife monitoring efforts that aim at quantifying the distribution, abundance and behavior of mobile species. However, the inference of these biological characteristics is not trivial due to the confounding factor of detection, which may vary greatly among camera trapping locations. Hence, variation in the rates at which a species is recorded (the photographic rate) may indeed reflect differences in local abundance, but might just as well reflect differences in the probabilities with which individuals are detected, or more likely a combination of both (see Burton et al., 2015; Sollmann, 2018, for two excellent reviews).

Since local detection rates are generally not known, both processes have to be inferred jointly. The most often used methods are variants of so-called occupancy models that treat the detection probability explicitly (MacKenzie et al., 2002). The basic quantity of interest in these models is whether or not a particular site is occupied by the focal species. While the detection of a species implies that the species is present, the absence of a record does not necessarily imply it is absent. Since the probabilities of detection and occupation are confounded, they can not be inferred for each site individually. It is therefore common to use hierarchical models that express detection probabilities as a function of environmental variables (MacKenzie et al., 2002).

Here we introduce `Tomcat`, a Time-dependent Occupancy Model for CAmera Trap data, that extends currently used occupancy models in three important ways:

First, we explicitly account for the sparsity among environmental coefficients. This is relevant since many environmental variables are generally available and it is usually not known which ones explain the variation in abundance of a species. Enforcing sparsity on the vector of coefficients avoids the problem of over-fitting in case the number of camera trap locations is smaller or on the same order as the number of environmental coefficients.

Second, we propose to quantify a measure of relative species density, namely the rate at which animals pass through a specific location, rather than occupancy. Quantifying occupancy assumes there exists a well defined patch or site that is either occupied by a species or not. The notation of a discrete patch is, however, often difficult when analyzing camera trap data of mobile species, which complicates interpretation (Efford and Dawson, 2012; Steenweg et al., 2018). In addition, summarizing camera trap data by a simple presenceabsence matrix ignores the information about differences in population densities at occupied sites. Occupancy is therefore not necessarily a good surrogate for abundance (Efford and Dawson, 2012; Steenweg et al., 2018; MacKenzie and Royle, 2005), even it has been advocated for birds (MacKenzie and Nichols, 2004).

By quantifying relative densities this limitation can be overcome as we do not need to make strict assumptions about the independence of camera trap locations. However, we note that relative densities do also not allow for an absolute quantification of density because it is not possible to distinguish mobility from abundance. However, they readily allow for the comparison of densities in space and hence to identify habitat important for a particular species. We further argue that it more useful than occupancy to monitor changes in species abundances over time as for many species, changes in population size will be reflected in the rate at which a species is detected prior to local extinction.

Finally, we extend classic occupancy models by jointly estimating daily activity patterns. Several models have been proposed to estimate such patterns from camera trap data (Frey et al., 2017), including testing for non-random distributions of trap events in predefined time-bins (Bu et al., 2016) and circular kernel density functions (Oliveira-santos et al., 2013; Rowcliffe et al., 2014), with latter allowing for the quantification of activity overlap between species (Ridout and Linkie, 2009). Jointly inferring activity patterns with relative densities allows us not only account for imperfect detection, but also extent the idea of overlap to space, shedding additional light on species interactions.

In this article, we begin by describing the proposed model in great details. We then verify its performance using extensive simulations and finally illustrate this idea by inferring spatio-temporal overlap of six Duiker species within the forest-savanna ecotone of central Africa.

## 2. The method

We present a Bayesian Time-dependent Occupancy Model for CAmera Trap data (`Tomcat`), suited to estimate relative event densities in space and time. Let us denote by Λ_{j}(*t*) the rate at which a camera trap at location *j* = 1, …, *J* takes pictures of a particular species (or guild) at the time of the day *t* ∈ [0, *T*], *T* = 24*h*. We assume that this rate is affected by three processes: 1) the average rate at which individuals pass through location *j*, 2) the daily activity patterns 𝒯 (*t*), and 3) the probability *p*_{j} with which an individual passing through location *j* is detected by the camera trap:

The number of pictures *W*_{j}(*d, t*_{1}, *t*_{2}) taken by a camera trap at location *j* within the interval [*t*_{1}, *t*_{2}) on day *d* is then given by the non-homogeneous Poisson process
with intensity function

A common problem to occupancy models is that the parameters related to species densities and detection probabilities, and *p*_{j} in our case, are confounded and can not be estimated individually for each location without extra information. However, it is possible to estimate relative differences between locations using a hierarchical model. Following others (e.g. Tobler et al., 2015), we assume that both parameters are functions of covariates (e.g. the environment), and hence only attempt to learn these hierarchical parameters. Here, we use
where *X*_{j} and *Y*_{j} are known (environmental) covariates at location *j* and *a, A* and *B* are species specific coefficients. Note that to avoid non-identifiability issues, we did not include an intercept for *p*_{j}, and hence we set the average detection probability across locations (assuming *X* and *Y* have mean zero). Also, *X*_{j} and *Y*_{j} should not contain strongly correlated covariates.

### 2.1. Non-independent events

Another issue specific to camera traps is that not every picture is necessarily reflective of an independent observation as the same individual might trigger multiple pictures while passing (or feeding) in front of a camera trap. It is often difficult and certainly laborious to identify such recurrent events. Here we account for non-independent events by dividing the day into *n*_{o} intervals of equal length (*o* for observation), and then only consider whether or not at least one picture was taken within each interval [*c*_{m−1}, *c*_{m}), *m* = 1, …, *n*_{o}, where *c*_{0} = *c*_{M} = *T*. Specifically, for an interval *m*,
where Λ_{j}(*c*_{m−1}, *c*_{m}) is given by (1).

### 2.2. Daily activity patterns

Here we assume that 𝒯(*t*) is a piece-wise constant function with *n*_{a} activity intervals of equal length (a for activity). While activity patterns are unlikely strictly piece-wise constant, we chose this function over a combination of periodic functions (e.g. Oliveira-santos et al., 2013) as they are fit to complicated, multi-peaked distributions with fewer parameters.

Since the best tiling of the day is unknown, we allow for a species-specific shift *δ* such that the first interval is [*δ, h*_{a} + *δ*) and the last overlaps midnight and becomes [*T* − *h*_{a} + *δ, δ*) (Figure 1). We therefore have
where the indicator function is 1 if *t* ∈ [*t*_{0}, *t*_{1}) and zero otherwise and *k*_{i} reflects the relative activity of the focal species (or guild) in interval *i* = 1, …, *n*_{h} with *k*_{i} = 0 implying no activity and *k*_{i} = 1 implying average activity. Note that
and hence

### 2.3. Bayesian inference

We conduct Bayesian inference on the parameter vector ** θ** = {

*a, A, B, δ*,

**}, where , by numerically evaluating the posterior distribution ℙ(**

*k***|**

*θ***) ∝ ℙ(**

*W***|**

*W***)ℙ(**

*θ***), where**

*θ***= {**

*W**W*

_{1}, …,

*W*

_{J}} denotes the full data from all locations

*j*= 1, …,

*J*.

The likelihood ℙ(** W**|

*θ*) is calculated as where ℙ(

*W*

_{j}(

*d, c*

_{m−1},

*c*

_{m})|

**) is given by equation (4) and the the product runs across all days**

*θ**D*

_{j1}, …,

*D*

_{j2}camera trap

*j*was active.

Since it is usually not known which covariates *X*_{j} and *Y*_{j} are informative, nor at which spatial scale they should be evaluated, the potential number of covariates to be considered may be large. To render inference feasible, we enforce sparsity on the vectors of coefficients *A* and *B*. Specifically, we assume that ℙ(*A*_{i} ≠ 0) = *π*_{λ} and, correspondingly, ℙ(*B*_{i} ≠ 0) = *π*_{p}.

We chose uniform priors on all other parameters, namely ℙ(*a*) ∝ 1, ℙ(** k**) ∝ 1 for all vectors of

**that satisfy , and ℙ(**

*k**δ*) ∝ 1 for all 0

*≤ δ < h*

_{a}. For simplicity, we only consider cases in which

*h*

_{a}, the length of the activity intervals, is a multiple of

*h*

_{o}, the length of the observation intervals, and allow only for discrete

*δ*∈ {0, …,

*h*

_{a}

*/h*

_{o}}. Finally, we set

*π*

_{p}=

*π*

_{λ}= 0.1.

We use a reversible-jump MCMC algorithm (Green, 1995) to generate samples from the posterior distribution ℙ(** θ**|

**). The update**

*W***→**

*k***′ is noteworthy. We begin by picking a random activity interval**

*k**i*and proposing a move according to a symmetric transition kernel. We then scale all other entries of

**′ to satisfy the constraint on the sum. Specifically, we set for all**

*k**j*≠

*i*, where

### 2.4. Prediction

Using a set of *S* posterior samples *θ*_{1}, …, *θ*_{S} ∼ ℙ(** θ**|

**), we project event densities to a not-surveyed location**

*W**ι*with covariates

*X*

_{ι}by calculating the mean of the posterior as where

*a*

^{(i)}and

*A*

^{(i)}denote the

*i*-th posterior sample of these parameters.

### 2.5. Species overlap in space and time

An important interest in ecology is to compare activity patterns among species and to see how overlapping patterns may relate to competition or predation (e.g. Ridout and Linkie, 2009; Rowcliffe et al., 2014).

We can quantify overlapping patterns of animal activity by estimating the coefficient of overlap Δ (Ridout and Linkie, 2009). This quantitative measure ranges from 0 (no overlap) to 1 (identical activity patterns) and is the area lying under two activity density curves (see Figure 4). For two known density functions *f* (*x*) and *g*(*x*), Δ is given by:

The overlap measure Δ(*f, g*) can be related to the well known measure of distance between two densities *L*_{1} as
which justifies the visualization of overlap coefficients between *k* species in a n-dimensional space using a Multidimensional Scaling (MDS) by considering as a measure of dissimilarity.

In practice, the true density functions *f* (*x*) and *g*(*x*) are usually not known. Here we obtain an estimate of Δ numerically from posterior samples. We distinguish three types of overlap coefficients, Δ_{T} for overlap in time, Δ_{S} for overlap in space and Δ_{ST} for overlap in time and space.

*Overlap coefficient* Δ_{T}

For a large number *n*_{T} of equally spaced time values , we sample from the posterior distribution ℙ(Δ_{T} |*W*^{(1)}, *W*^{(2)}) where denotes the full data for a species *l* = 1, 2.
where is computed according to equation (5) with species specific parameters and sampled from ℙ(*θ*_{l}|*W*^{(l)}).

*Overlap coefficient* Δ_{S}

For a given number *n*_{S} of sites reflecting the habitat in a region, we sample from the posterior distribution ℙ(Δ_{S} |*W*^{(1)}, *W*^{(2)}) as
where is computed according to equation (2) and normalized such as with species specific parameters and sampled from ℙ(*θ*_{l}|*W*^{(l)}).

*Overlap coefficient* Δ_{ST}

For *n*_{T} time values and *n*_{S} number of sites, we sample from the posterior distribution ℙ(Δ_{ST} |*W*^{(1)}, *W*^{(2)}) as
where for species *l* = 1, 2 we calculate according to equation (5) and according to equation (2) with species specific parameters , and sampled from ℙ(*θ*_{l}|*W*^{(l)}), but normalized such that

##### Implementation

All methods were implemented in the `C++` program `Tomcat`, available through a git repository at https://bitbucket.org/WegmannLab/tomcat/.

## 3. Performance against simulations

We assessed the performance of our algorithm using 100 replicates for each combination of *J* = 20 or 100 camera trap locations and *D* = 1, 2, 5, 10, 20, 50 or 100 days at which data was collected. All simulations were conduced with one-dimensional *X*_{j} ∼ *N* (0, 1) and *Y*_{j} ∼ *N* (0, 1) and parameter choices such that on average one picture per species per location was expected, and hence the expected number of pictures per species was *JD*.

To evaluate the accuracy of our estimates, we then estimated the overlap between two species since errors in parameter estimates directly translate into biases in overlap coefficients. We thus simulated data for two species with little (Δ_{T} = 0.2), moderate overlap (Δ_{T} = 0.5) or large overlap in time (Δ_{T} = 0.8) as described in Table 1, as well as for two species with varying overlap in space (Δ_{S} = 0.2, 0.5, and 0.8) and for with varying overlap in space and time (Δ_{ST} = 0.2, 0.5, and 0.8) as described in the Appendix.

As shown in Figure 2, the posterior means and were unbiased and highly accurate for all overlap coefficients if sufficient data is provided, i.e. if at least several hundred pictures were available (*J × D ≥* 500). If less data was available, estimates were biased towards the prior expectations of Δ_{T} = 0.5 and Δ_{S} = 1.

## 4. Application to central African duikers

We applied `Tomcat` to camera trapping data obtained during the dry seasons from 2012 to 2018 from a region in the Eastern Central African Republic (CAR), a wilderness exceeding 100000 km^{2} without permanent settlements, agriculture or commercial logging (Aebischer et al., 2017). The Eastern CAR consists of an ecotone of tropical moist closed canopy forests of the Northeastern Congolian lowland rain forest biome and a Sudanian-Guinean woodland savanna that is interspersed with small patches of edaphic grasslands on rocky ground or swampy areas (Boulvert, 1985; Olson and Dinerstein, 1998).

The available data was from 532 locations that cover the Chinko Nature Reserve (CNR), a protected area of about 20000 km^{2} that was established in 2014 by the government of the CAR in former hunting zones. Here, we use `Tomcat` to study duikers (Cephalophinae), which are a diverse mammalian group common in the data set and observed often in sympatry, i.e. several species were captured by the same camera trap within a few hours. We detected a total of eight species in the data set (Table 2): *Cephalophus dorsalis castaneus* (Eastern Bay Duiker), *Cephalophus leucogaster arrhenii* (Uele White Bellied Duiker), *Cephalophus nigrifrons* (Black Fronted Duiker), *Cephalophus rufilatus* (Red Flanked Duiker), *Cephalophus silvicultor castaneus* (Western Yellow Backed Duiker), *Cephalophus weynsi* (Weyns Duiker), *Philantomba monticola aequatorialis* (Eastern Blue Duiker) and *Sylvicapra grimmia* (Bush Duiker).

To infer habitat preferences for these species, we benefited from an existing land cover classification at a 30m resolution that represents the five major habitat types of the Chinko region: Closed Canopy Forest (CCF), Open Savanna Woodland (OSW), Dry Lakr Grassland (DLG), Wet Marshy Grassland (WMG) and Surface Water (SWA) (Aebischer et al., 2017). Around every camera trap location and 10,200 regular grid points spaced 2.5 km apart and spanning the entire CNR, we calculated the percentage of each of these habitats in 11 buffers of sizes 30, 65, 125, 180, 400, 565, 1260, 1785, 3,990, 5,640 and 17,840 meters. We complemented this information with the average value within every buffer for each of 15 additional environmental and bioclimatic variables from the WorldClim database version 2 (Table E.1 Fick and Hijmans, 2017) that we obtained at a resolution of 30 seconds, which translates into a spatial resolution of roughly 1km^{2} per grid cell. To aid in the interpretation, we then processed our environmental data by 1) keeping only the additional effect of each variables after regressing out the habitat variables CCF and OSW at the same buffer, and by 2) keeping only the additional effect of every variable after regressing out the information contained in the same variable but at smaller buffers (see Appendix for details).

To avoid extrapolation, we restricted our analyses to 2,639 grid locations that exhibited similar environments to those at which camera traps were placed as measured by the Mahanalobis distance between each grid point and the average across all camera trap locations (see Appendix for details).

For each location we further used the binary classification of the four most common habitat types (CCF, OSW, MWG, DLG) and determined the presence or absence of six additional habitat characteristics: Animal path, road, salt lick, mud hole, riverine zone and bonanza.

The eight duiker species varied greatly in both their habitat preferences (Figures 3, S.2) and their daily activity patterns (Figures 4, S.1) as inferred by `Tomcat`). As shown in Figure 3, *C. dorsalis* and *C. weynsi* have both a strong preference for CCF over OSW habitat at the smallest buffers, in contrast to *S. grimmia* that shows a string preference of OSW. At higher buffers, the signal is less clear, probably owing to the heterogeneous nature of the habitat in which both CCF and OSW correlated negatively with WMG and DLG, habitats not well suited for all these species. Interestingly, two species (*P. monticola* and *C. silvicultor*) also seem to be true ecotome species preferring a mixture of the canonical habitats CCF and OSW (Figure S.2). Similarly, and as shown in Figure 4, some species appear to be almost exclusively nocturnal (*C. dorsalis* and *C. silvicultor*), some almost exclusively diurnal (*C. leucogaster, C. monticola, C. nigrifons, C. rufilatus, C. weynsi*) and one crepuscular (*S. grimmia*).

To better understand how these closely related duiker species of similar size and nutrition can occur sympatrically, we estimated pairwise overlap coefficients in space and time (Figure 4, Table E.2). Not surprisingly, most species pairs differed substantially either in their habitat preference of daily activity patterns. Of the two forest dwellers *C. dorsalis* and *C. weynsi* , for instance, one is almost exclusively nocturnal and the other almost exclusively diurnal , resulting in a small overlap in space and time . Similarly, the nocturnal *C. dorsalis* and the crepuscular *S. grimmia* that share a lot of temporal overlap use highly dissimilar habitats , resulting in a very small overlap in time and space .

A visualization using Multidimensional Scaling (MDS) of the pair-wise over-lap coefficients of all six species with events from at least 50 independent camera trap locations is shown in Figure 5. For these species, 88.3% of variation in the temporal overlap can be explained by a single axis separating nocturnal from diurnal species. In contrast, only 45.6% of the variation in the spatial overlap is explained by the first axis distinguishing forest dwellers from savanna species.

When using both temporal and spatial information, it is striking that frequently observed and therefore evidently abundant species within a certain community tend to differ in their habitat preference and/or daily activity. In contrast, infrequently observed and therefore putative rare taxa seem to have large overlap with co-occurring species. The Uele white-bellied duiker (*C. leucogaster*), for instance, which is rather rare and was only observed at eleven distinct locations (Table 2), depends on similar food and is active at the same time as the Weyns duiker (*C. weynsi*), which is among the most common forest duikers within the CNR. In contrast, the Eastern Bay duikers (*C. dorsalis*), which is strictly nocturnal, seems to co-exist with the Weyns duikers at higher densities (Figure (4).

## Conclusion

Despite a world-effort to assess biodiversity, there are still major areas for which almost no information is available on biodiversity (e.g. Hickisch et al., 2019). But several technological advances, and in particular camera traps and voice recorders, make it possible to obtain a first glimpse on the presence and distribution of larger or highly vocal animals such as mammals and birds in relatively short time with a reasonable budget. Thanks to technical advances, increased battery life and larger media to store data, such data sets can now be produced with comparatively little manpower, even under the demanding conditions in large and remote areas. In addition, the annotation of such data sets on the species level is now aided by machine learning algorithms that automatize the detection of at least common species and images without animals (e.g. **?**). Thanks to these developments, existing knowledge gaps may now be increasingly addressed, allowing for a re-evaluation of conservation strategies and optimization of conservation management.

Here we introduce `Tomcat`, a occupancy model that infers habitat preference and daily activities from such data sets. Unlike many previous methods that estimate the presence or absence of a species, `Tomcat` estimates relative species densities, from which overlap coefficients between species can be estimated in space and time, while accounting for variation in detection probabilities between locations. While estimates of overlap coefficients require larger data sets than the inference of pure occupancy, we believe they constitute a major step forward in understanding the complex species interactions in an area, which are particularly relevant for conservation planning in heterogeneous or fragmented habitat.

## Appendix A. Simulating data with specific overlap coefficients

### Simulating data with specific Δ_{S}

For the simulation of scenarios with a given Δ_{S}, we have simulated for each site *j*, an environmental variable *X*_{j} from *N* (0, 1). Δ_{S} will be estimated with , where
where in presence of *n* sites. For a species *i* and site is given by equation (2), with the constraint :
We have for species 1 :

Equivalently, we have for species 2, . Therefore,

We have We have The integral in equation (S.4) is given by: where Φ represents the cumulative distribution function (CDF) of the standard normal distribution.

Finally, we have
It is possible using equation (S.5) to simulate a model for which Δ_{S} = *a*.

For example, for Δ_{S} = *δ*_{s}, and for *A*_{1} = *a*_{1}, it is possible to get the value of *A*_{2} from (S.5), which gives
After computing *A*_{2}, it is easy to deduce the value of *µ*_{2} using equation (S.2).

### Simulating data with specific Δ_{ST}

To simulate scenarios for a given Δ_{ST}, we have simulated for each site *j* an environmental variable *X*_{j} from *N* (0, 1), and *T* ∼ *U*_{[0,24]}. Δ_{ST} is estimated using equation (11).

For a species *i* and site *j*, we have the constraint
where 𝒯_{i}(*t*) is the daily activity for a species *i, i* = 1, 2 observed at time *t*.

We have
and
which gives
We can therefore simulate the scenario Δ_{ST} = *δ*_{ST} with known activity patterns 𝒯_{1}, 𝒯_{2} respectively for species 1 and 2 as follows:

Simulate

*n*_{s}*X*_{j}∼*N*(0, 1),*j*= 1, 2, …*n*_{s}.Propose a value of

*A*_{1}. (Should not be very large. Namely between −2 and 2).Compute the value of

*µ*_{1}using equations (S.7).Compute numerically the value of

*A*_{2}by solving the equation :Using

`Tomcat`for the two species, and by fixing the value*A*_{i},*i*= 1, 2, we can sample from the posterior distribution of Δ_{ST}and compute the posterior mean of the values Δ_{ST}using equation (11).

## Appendix B. Decorrelation environmental variables

While `Tomcat` readily handles correlated environmental variables, we chose to decorrelate specific variables to aid in interpretation. Specifically, we processed our environmental data as follow (two steps):

Step 1: A major interest in our application was to study the impact of the prevalence of close canopy forest (*f*) and savanna (*s*) habitat on species densities. For each scale (buffer) *b*, we therefore regress each environmental variable *V*_{ib}, *i* ≠ *f, s*:
where *V*_{fb} and *V*_{sb} represents, respectively, the forest and the Savannah habitat for a buffer *b* = 1, …, *B, i* = 1, …, *n*_{env}, and *ϵ*_{ib} is the error from the linear model described by equation (S.1), which captures the information of the variable *V*_{ib} independent of *V*_{fb} and *V*_{sb} at buffer *b*. We therefore replace the *V*_{ib} variables by in our model, but kept and .

Step 2: To evaluate relevant spatial scale of environmental variables, we also regressed out the larger buffers from the smaller one as: In the second step, and for a given environmental variable at the scale, we give priority to the smaller scales by keeping only the additional explanation by the studied variable to what we already know by replacing by .

## Appendix C. Restricting analysis to environmentally homogeneous regions

Let be a matrix where the rows represent the observed camera traps, and the columns the environmental variables, and let a matrix containing the environmental variables for the locations for which we want to predict .

We define the Mahanalobis distance *D*_{O} of given by
where , and *S* is the variance covariance matrix.

We define a second Mahalanobis distance *D*_{P} which measures the distance of from the the mean of the camera traps environmental variables. *D*_{P} is given by
After computing *D*_{O} and *D*_{P}, we decided to remove the grid points for which we have *D*_{P} > 1.2 × max(*D*_{O}).