This function provides general fixes to common issues of capture-mark-recapture (CMR) data.
FixCMRdata(object, studyStart, studyEnd, autofix = rep(0, 6),
silent = TRUE)
For dataType
= “CMR
”:
A corrected data frame.
A vector of row numbers in the original data frame where there are deaths occurring before the study starts.
A vector of row numbers in the original data frame where there are no birth/death AND no obervations.
A vector of row numbers in the original data frame where there are births recorded after death.
A vector of row numbers in the original data frame where there are observations (i.e. recaptures) after death.
A vector of row numbers in the original data frame where there are observations (i.e. recaptures) before birth.
A vector of row numbers in the original data frame where the year of birth is not a zero in the recapture matrix.
Logical that indicates if the data are free of errors or not. i.e. TRUE
= the data have no apparent errors, and FALSE
= there is at leat one error.
A data.frame to be used as an input data file for BaSTA for dataType =
“CMR
”. The first column is the individual's ID, the second and third columns are birth and death years respectively. Columns 4 to nt+3
represent the observation window of nt years. This is followed (optionally) by columns for covariate.
An integer indicating the first year of the study.
An integer indicating the last year of the study.
A vector argument with a length of 6 indicating whether to automatically fix any errors (see details
). This should be used with extreme caution. We recommend going back to the individual-based data and fixing each error “by hand”.
A logical argument indicating whether to print a detailed report to the screen or not.
Fernando Colchero fernando_colchero@eva.mpg.de
Argument autofix
allows the user to fix the potential errors by specifying a code for each fix. Below are the descriptions of the actions that are taken depending on the error type and the fix code:
Type 1: 0 = do nothing; 1 = remove from dataframe.
Type 2: 0 = do nothing; 1 = remove from dataframe.
Type 3: 0 = do nothing; 1 = replace death records with 0; 2 = replace birth records with 0; 3 = replace both birth and death records with 0.
Type 4: 0 = do nothing; 1 = remove spurious post-death observations.
Type 5: 0 = do nothing; 1 = remove observations that pre-date year of birth.
Type 6: 0 = do nothing; 1 = replace birth year element of observation matrix with 0.
DataCheck
for running a data check on the input data for function basta
.
## Load data:
data("bastaCMRdat", package = "BaSTA")
## Fix data:
fixedData <- FixCMRdata(bastaCMRdat, studyStart = 51,
studyEnd = 70, autofix = rep(1, 6))
Run the code above in your browser using DataLab