FixCMRdata {BaSTA}R Documentation

Fix issues on CMR input data for BaSTA.

Description

This function provides general fixes to common issues of capture-mark-recapture (CMR) data.

Usage

FixCMRdata(object, studyStart, studyEnd, autofix = rep(0, 6), 
                       silent = TRUE)

Arguments

object

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.

studyStart

An integer indicating the first year of the study.

studyEnd

An integer indicating the last year of the study.

autofix

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”.

silent

A logical argument indicating whether to print a detailed report to the screen or not.

Details

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.

Value

For dataType = “CMR”:

newData

A corrected data frame.

type1

A vector of row numbers in the original data frame where there are deaths occurring before the study starts.

type2

A vector of row numbers in the original data frame where there are no birth/death AND no obervations.

type3

A vector of row numbers in the original data frame where there are births recorded after death.

type4

A vector of row numbers in the original data frame where there are observations (i.e. recaptures) after death.

type5

A vector of row numbers in the original data frame where there are observations (i.e. recaptures) before birth.

type6

A vector of row numbers in the original data frame where the year of birth is not a zero in the recapture matrix.

stopExec

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.

Author(s)

Fernando Colchero fernando_colchero@eva.mpg.de

See Also

DataCheck for running a data check on the input data for function basta.

Examples

## Load data:
data("bastaCMRdat", package = "BaSTA")

## Fix data:
fixedData  <- FixCMRdata(bastaCMRdat, studyStart = 51, 
                          studyEnd = 70, autofix = rep(1, 6))

[Package BaSTA version 2.0.0 Index]