CensusToCaptHist {BaSTA} | R Documentation |
Constructs a capture-history matrix from repeated individual observations to be used in Bayesian Survival Trajectory Analysis (BaSTA).
Description
This function takes a table of repeated observations per individual (e.g., discrete interval census), consisting of a pair of vectors with ID and observation date (e.g., year), and converts it into a capture-history matrix to be used as part of a BaSTA CMR data input.
Usage
CensusToCaptHist(ID, d, dformat = "%Y", timeInt = "Y")
Arguments
ID |
A vector with individual IDs. |
d |
A vector of dates when each individual was observed (see |
dformat |
Defines the date format for |
timeInt |
A one character string specifying which time interval should be used between capture occasions. Arguments are “ |
Details
The d
argument can be specified as an object of class POSIXct
or POSIXlt
, as a vector of integer time intervals or as a character string indicating the day, month and year. (e.g. dd/mm/yyyy
, mmddyyyy
, mm-dd-yyyy
etc.). When d
is of class character
then argument dformat
needs to be specified using the same conventions as in function format.POSIXct
for objects of class POSIXct
or POSIXlt
.
Value
Creates an object of class “data.frame
” with the reconstructed capture recapture matrix.
Author(s)
Owen R. Jones jones@biology.sdu.dk.
See Also
DataCheck
for running a data check on the input data for function basta
.FixCMRdata
to fix potential issues for capture-mark-recapture data. bastaCMRdat
for an example of input CMR datasets.
Examples
## Create a simulated vector of repeated IDs:
IDvec <- sort(sample(1:5, size = 15, replace = TRUE))
## Simulate dates (e.g., years) of observation per individual:
dVec <- rep(0, length(IDvec))
for(i in unique(IDvec)) {
svec <- which(IDvec == i)
dVec[svec] <- sort(sample(1990:1995, length(svec)))
}
## Construct the capture-recapture matrix:
Y <- CensusToCaptHist(ID = IDvec, d = dVec)