as.rateData: Conversion among data and phylogeny objects

Description Usage Arguments Value Author(s) References Examples

View source: R/as.rateData.R

Description

Function to generate a "rateData" object containing the discrete explanatory variable, continuous response variable and set of variance co-variance matrices. It loads the trait data and removes species with missing data from the data and vcv matrix. as.rateData requires either a set of matrices in rateMatrix format created using as.rateMatrix or, if no rateMatrix object is input then it requires a phylogeny in "phylo" format. If a "phylo" object is used as.rateData will call as.rateMatrix internally. as.rateMatrix calls the "ape" function vcv.phylo multiple times and this can be slow for large phylogenies. It will often be more efficient to use as.rateMatrix first to create a "rateMatrix" object to pass to as.rateData, particularly if there are many response traits of interest to be fitted to the same phylogeny and set of reconstructed ancestral states.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
as.rateData(
  y,
  x,
  rateMatrix = NULL,
  phy = NULL,
  data,
  meserr.col = NULL,
  meserr.propn = NULL,
  log.y = FALSE,
  report_prune = FALSE
)

Arguments

y

The response variable - typically a continuous trait. Specified as a column name or index

x

The explanatory (discrete) variable used to define the hypothesised rate categories. Specified as a column name or index.

rateMatrix

A "rateMatrix" object or NULL

phy

An object of class "phylo" (see ape).

data

A data frame containing (minimally) the x and y variables as columns with species names as rownames.

meserr.col

Column name or index containing measurement error for species means.

meserr.propn

Single value specifying the proportional measurement to be applied across all species.

log.y

Logical, natural log transform response variable.

report_prune

Logical. Prints a list of dropped species if TRUE

Value

rateData An object of class "rateData" which is a list containing the response (y) and explanatory (x) variable along with a list of variance-covaraince matrices.

Author(s)

Gavin Thomas

References

Thomas GH, Meiri S, & Phillimore AB. 2009. Body size diversification in Anolis: novel environments and island effects. Evolution 63, 2017-2030.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Read in phylogeny and data from Thomas et al. (2009)
data(anolis.tree)
data(anolis.data)

## Convert data to class rateData with a rateMatrix object as input
anolis.rateMatrix <- as.rateMatrix(phy=anolis.tree, x="geo_ecomorph", data=anolis.data)

anolis.rateData <- as.rateData(y="Female_SVL", x="geo_ecomorph", 
rateMatrix = anolis.rateMatrix, phy=NULL, data=anolis.data, log.y=TRUE)  

## Convert data to class rateData with a phylo object as input 
anolis.rateData <- as.rateData(y="Female_SVL", x="geo_ecomorph", 
rateMatrix = NULL, phy=anolis.tree, data=anolis.data, log.y=TRUE)

motmot documentation built on Jan. 11, 2020, 9:15 a.m.