R programs for estimating overlap of activity patterns

This page provides R programs to estimate the degree of overlap between the activity patterns of two species, based on camera trap data. R is a free statistics package available from the Comprehensive R Archive Network.

The statistical methodology is described in [Ref 1] and [Ref 2] below. The data consist of times of day of photographs of different species, from camera trap records. These data are used to estimate the activity pattern of each species over the day (as a probability density function) and then, for a given pair of species, the degree of overlap between the two estimated densities can be estimated.

Statistical method

In statistical terminology, time of day records are an example of circular data. Activity patterns are obtained either by kernel density estimation or by fitting a flexible parametric family of circular distributions called trigonometric sum distributions [Ref 3].

The measure of overlap used is the coefficient of overlapping [Ref 4], which is the area under the curve that is formed by taking the minimum of the two density functions at each time point. This is denoted by Delta in the papers and can range from 0 (no overlap, e.g. one species entirely diurnal, the other entirely nocturnal) to 1 (complete overlap, identical activity patterns). A useful interpretation is that for any time period during the day, the proportion of activity that occurs during that period differs between the two species by less than 1-Delta.

Implementation in R

The data from [Ref 2] are in file traptimes.txt. The file setup.r reads the data into R and also imports a set of functions that are used in the analyses (these functions are in the file ovlcode.r).

NOTE: The file ovlcode.r was last updated 16/11/12 to fix a bug. Also, it has become apparent that the bootstrap procedure for finding confidence intervals for the estimated overlap is not reliable. In particular it may give very poor coverage if the true overlap is high. This is not a programming bug; it is simply that the basic bootstrap procedure is not reliable in this situation. Improved methods for constructing confidence intervals are currently under investigation.

The file example.r provides simple examples of how to estimate overlap, including a bootstrap confidence interval. To run the example (which should take less than a minute on a modern PC), follow these steps:

• copy ALL the R files and the data file into a directory on your computer
• start R and click on File|Change dir... to select the directory where you stored the files
• At the R prompt (> ) type
source("example.r")

The files figure1.r and figure2.r produce the two figures in ref [2]. These files are included for the benefit of anyone interested in producing similar graphs, but they are not extensively commented.

References

[1] Ridout, M.S. and Linkie, M. (2009) Estimating overlap of daily activity patterns from camera trap data. Journal of Agricultural, Biological and Environmental Statistics, 14, 322-337. [Journal link]

[2] Linkie, M. and Ridout, M.S. (2011) Assessing tiger-prey interactions in Sumatran rainforests. Journal of Zoology, 284, 224-229. [Journal link]

[3] Fernandez-Duran, J.J. (2004) Circular distributions based on non-negative trigonometric sums. Biometrics, 60, 499-503.

[4] Weitzman, M.S. (1970) Measures of overlap of income distributions of white and negro families in the United States. Technical Report 22, US Department of Commerce, Bureau of the Census, Washington DC.