Skip to content

Instantly share code, notes, and snippets.

@nmatzke
Created July 23, 2016 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmatzke/31f917433a5773816bb1a4e9f652e7ed to your computer and use it in GitHub Desktop.
Save nmatzke/31f917433a5773816bb1a4e9f652e7ed to your computer and use it in GitHub Desktop.
Converting between birth rate, death rate (speciation and extinction) and r (diversification rate) and epsilon (relative death rate)
# Example converting between
# birth rate, death rate (speciation and extinction)
# and
# r (diversification rate) and epsilon (relative death rate)
library(ape)
library(BioGeoBEARS)
# Load the Psychotria tree
trfn = np(paste(addslash(extdata_dir), "Psychotria_5.2.newick", sep=""))
tr = read.tree(trfn)
# Estimate the rates (this is a simple method in APE,
# see geiger for more sophisticated options)
# birthrate means: speciation rate
# deathrate means: extinction rate
#
# Note: the lineage extinction rate is a different thing
# from the "e" in DEC, which is a range of range
# contration
#
birthdeath_results = birthdeath(tr)
birthdeath_results
diversification_rate = birthdeath_results$para["b-d"]
relative_extinction_rate = birthdeath_results$para["d/b"]
birthrate = diversification_rate / (1-relative_extinction_rate)
deathrate = relative_extinction_rate * birthrate
birthrate
deathrate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment