Site menu:
R code for estimating overlap of activity patterns
This page originally provided R functions to estimate the degree of overlap between the activity patterns of two species, based on camera trap data. The original page and the code are retained below for completeness, but the code is now superceded by the R package overlap, developed from the original code by Mike Meredith (more details).
The package, which is for R version 3.0 onwards, is available on the
Comprehensive R Archive Network
and can be installed from within R via the menus or by typing
install.packages("overlap")
at the R prompt.
The package offers significant improvements in computational speed and now provides several different types of bootstrap confidence interval, some of which are better than those suggested originally. A User Manual is available that includes practical advice on what settings to use, depending on sample sizes, and how to interpret the output. The data set described on this page is available from within the package.
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 1Delta.
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).
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 FileChange 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, 322337. [Journal link]
[2] Linkie, M. and Ridout, M.S. (2011) Assessing tigerprey interactions in Sumatran rainforests. Journal of Zoology, 284, 224229. [Journal link]
[3] FernandezDuran, J.J. (2004) Circular distributions based on nonnegative trigonometric sums. Biometrics, 60, 499503.
[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.