MakeCovMat: Function to build a matrix of covariates (i.e. design matrix)...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/MakeCovMat.R

Description

This function creates a matrix of covariates or design matrix appropriate for BaSTA from raw individual level covariate data. The function identifies categorical and continuous covariates and organizes them accordingly.

Usage

1

Arguments

x

A character string vector or a numerical vector indicating the columns to be included or an object of class formula.

data

A data frame of n rows (n = number of individuals in dataset) and nz columns (number of general covariates) including categorical covariates as factors (e.g. sex with individual labels "f","m", location, etc.) and/or continuous individual covariates (e.g. weight at birth, general weather conditions at each location, etc.).

Details

The x argument can be of class character, numeric or formula as long as the elements described correspond to the column names in the data data frame. The data frame specified in argument data needs to explicitly differentiate between categorical and numerical variables. The elements in the column of a categorical variable must be coerced to be factors.

Value

The function returns a new covariate matrix to be collated to a matrix that includes a column for individual ID, a column for time of birth, and a column for times of death, plus the full recapture matrix.

Author(s)

Owen R. Jones [email protected] and Fernando Colchero [email protected]

See Also

basta

Examples

1
2
3
4
5
## Simulated sex and weight data for 5 individuals:
sex        <- sample(c("f", "m"), 5, replace = TRUE)
weight     <- rnorm(5, mean = 10, sd = 1)
raw.mat    <- data.frame(sex, weight)
new.mat    <- MakeCovMat(~sex + weight, data = raw.mat)

Example output



BaSTA documentation built on May 29, 2017, 2 p.m.