capthist
object from a data frame of capture records and a traps
object.make.capthist(captures, traps, fmt = "trapID", noccasions = NULL,
covnames = NULL, bysession = TRUE, sortrows = TRUE, cutval = NULL,
tol = 0.01)
traps
describing an array of passive detectorscapthist
(a matrix or array of
detection data with attributes for detector positions etc.). For
'single' and 'multi' detectors this is a matrix with one row per animal
and one column per occasion (dim(capthist)=c(nc,noccasions)); each
element is either zero (no detection) or a detector number (the row
number in traps
not the row name). For 'proximity'
detectors capthist
is an array of values {-1, 0, 1} and
dim(capthist)=c(nc,noccasions,ntraps). The number of animals nc
is determined from the input, as is noccasions
if it is not specified.
traps
, covariates
and other data are retained as
attributes of capthist
.
Deaths during the experiment are represented as negative values in capthist
.
If the input has data from multiple sessions then the output is an
object of class c('list','capthist') comprising a list of single-session
capthist
objects.make.capthist
is the recommended way to prepare data for
secr.fit
. Each row of the input data frame represents a detection
on one occasion. The capture data frame may be formed from a text file
with read.captures
.
Input formats are based on the Density software (Efford 2007). If
fmt
= 'XY' the required fields are (session, ID, occasion, x, y)
in that order. If fmt
= 'trapID' the required fields are
(session, ID, occasion, trap), where trap
is the numeric index of
the relevant detector in traps
. session
and ID
may
be character-, vector- or factor-valued; other required fields are
numeric. Fields are matched by position (column number), not by
name. Columns after the required fields are interpreted as individual
covariates that may be continuous (e.g., size) or categorical (e.g., age, sex).
If captures
has data from multiple sessions then traps
may
be either a list of traps
objects, one per session, or a single
traps
object that is assumed to apply throughout. Similarly,
noccasions
may be a vector specifying the number of occasions in
each session.
Covariates are assumed constant for each individual; the first
non-missing value is used. The length of covnames
should equal the
number of covariate fields in captures
.
bysession
takes effect when the same individual is detected in
two or more sessions: TRUE results in one capture history per session,
FALSE has the effect of generating a single capture history (this is not
appropriate for the models currently provided in captures
. Occasions should be numbered 1, 2, ..., noccasions. By
default, the number of occasions is the maximum value of 'occasion' in
captures
.capthist
, traps
, read.captures
, secr.fit
, sim.capthist
## load demonstration data and peek at XY data
data(rawdata)
captXY[1:5,]
trapXY[1:5,]
demotraps <- read.traps(data = trapXY)
demoCHxy <- make.capthist (captXY, demotraps, fmt = 'XY')
demoCHxy ## print method for capthist
plot(demoCHxy) ## plot method for capthist
summary(demoCHxy) ## summary method for capthist
Run the code above in your browser using DataLab