Learn R Programming

BAMMtools (version 2.1.0)

getTipRates: Compute tip-specific macroevolutionary rates from bammdata object

Description

Return speciation, extinction, net diversification, or Brownian motion trait rates for all species in the phylogeny from BAMM output.

Usage

getTipRates(ephy, returnNetDiv = FALSE, statistic = 'mean')

Arguments

ephy
an object of class bammdata.
returnNetDiv
logical. If TRUE, then net diversification rates are returned, if FALSE, then both speciation and extinction rates are returned. If ephy is of type trait, then this is ignored.
statistic
Determines how the average tip rates should be calculated. Can be either mean or median.

Value

  • Returns a list with the following elements: If ephy type is 'diversification':
  • lambdaA matrix of tip speciation rates with species as rows, and posterior samples as columns.
  • muA matrix of tip extinction rates with species as rows, and posterior samples as columns.
  • lambda.avgA vector of average tip speciation rates, averaged with mean or median, depending on selected option for statistic. The vector is named with species names.
  • mu.avgA vector of average tip extinction rates, averaged with mean or median, depending on selected option for statistic. The vector is named with species names.
  • If ephy type is 'diversification' and returnNetDiv = TRUE:
  • netdivA matrix of tip net diversification rates with species as rows, and posterior samples as columns.
  • netdiv.avgA vector of average tip net diversification rates, averaged with mean or median, depending on selected option for statistic. The vector is named with species names.
  • If ephy type is 'trait':
  • betaA matrix of tip phenotypic rates with species as rows, and posterior samples as columns.
  • beta.avgA vector of average tip phenotypic rates, averaged with mean or median, depending on selected option for statistic. The vector is named with species names.

See Also

Requires an object of class bammdata as obtained with getEventData.

Examples

Run this code
data(whales, events.whales)
ephy <- getEventData(whales, events.whales, burnin=0.25, nsamples = 500)

#return a vector of average species-specific speciation rates.
meanlam <- getTipRates(ephy, returnNetDiv = FALSE, statistic = 'mean')$lambda.avg
meanlam

#return a vector of median species-specific net diversification rates.
ndr <- getTipRates(ephy, returnNetDiv = TRUE, statistic = 'median')$netdiv.avg


#Return mean species-specific speciation rates from all posterior 
#	samples in the \code{bamm-data} object.
lam <- getTipRates(ephy, returnNetDiv = FALSE, statistic = 'mean')$lambda
rowMeans(lam)

Run the code above in your browser using DataLab