CensusToCaptHist: Constructs capture-history matrix from census matrix to be...

View source: R/CensusToCaptHist.R

CensusToCaptHistR Documentation

Constructs capture-history matrix from census matrix to be used in Bayesian Survival Trajectory Analysis (BaSTA).

Description

This function takes a common census table, consisting of a pair of vectors with ID and observation date, and converts it into a capture-history matrix to be used as part of a BaSTA 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.

dformat

Defines the date format for d when d is of class character.

timeInt

A one character string specifying which time interval should be used between capture occasions. Arguments are “Y” for years, “M” for months, “W” for weeks and “D” for days.

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.

Author(s)

Owen R. Jones jones@demogr.mpg.de and Maren Rebke rebke@demogr.mpg.de

See Also

MakeCovMat, which formats a covariate matrix compatible with this output.

Examples

id.vec <- sort(sample(1:5, size = 15, replace = TRUE))
d.vec <- rep(0, length(id.vec))
for(i in unique(id.vec)){
  svec <- which(id.vec == i)
  d.vec[svec] <- sort(sample(1990:1995, length(svec)))
}
Y <- CensusToCaptHist(ID = id.vec,  d = d.vec)

BaSTA documentation built on Oct. 5, 2022, 5:06 p.m.