Description Usage Arguments Details Value Author(s) References Examples
View source: R/likelihood_bd.R
Computes the likelihood of a phylogeny under a birthdeath model with potentially timevarying rates and potentially missing extant species. Notations follow Morlon et al. PNAS 2011.
1 2 
phylo 
an object of type 'phylo' (see ape documentation) 
tot_time 
the age of the phylogeny (crown age, or stem age if known). If working with crown ages, tot_time is given by max(node.age(phylo)$ages). 
f.lamb 
a function specifying the timevariation of the speciation rate λ. This function as a single argument (time). Any function may be used. 
f.mu 
a function specifying the timevariation of the speciation rate μ. This function as a single argument (time). Any function may be used. 
f 
the fraction of extant species included in the phylogeny 
cst.lamb 
logical: should be set to TRUE only if f.lamb is constant (i.e. does not depend on time) to use analytical instead of numerical computation in order to reduce computation time. 
cst.mu 
logical: should be set to TRUE only if f.mu is constant (i.e. does not depend on time) to use analytical instead of numerical computation in order to reduce computation time. 
expo.lamb 
logical: should be set to TRUE only if f.lamb is exponential to use analytical instead of numerical computation in order to reduce computation time. 
expo.mu 
logical: should be set to TRUE only if f.mu is exponential to use analytical instead of numerical computation in order to reduce computation time. 
dt 
the default value is 0. In this case, integrals in the likelihood are computed using R "integrate" function, which can be quite slow. If a positive dt is given as argument, integrals are computed using a piecewise contant approximation, and dt represents the length of the intervals on which functions are assumed to be constant. For an exponential dependency of the speciation rate with time, we found that dt=1e3 gives a good tradeoff between precision and computation time. 
cond 
conditioning to use to fit the model:

When specifying f.lamb and f.mu, time runs from the present to the past (hence if the speciation rate decreases with time, f.lamb must be a positive function of time).
the loglikelihood value of the phylogeny, given f.lamb and f.mu
H Morlon
Morlon, H., Parsons, T.L. and Plotkin, J.B. (2011) Reconciling molecular phylogenies with the fossil record Proc Nat Acad Sci 108: 1632716332
1 2 3 4 5 6 7 8 9  data(Cetacea)
tot_time < max(node.age(Cetacea)$ages)
# Compute the likelihood for a pure birth model (no extinction) with
# an exponential variation of speciation rate with time
lamb_par < c(0.1, 0.01)
f.lamb < function(t){lamb_par[1] * exp(lamb_par[2] * t)}
f.mu < function(t){0}
f < 87/89
lh < likelihood_bd(Cetacea,tot_time,f.lamb,f.mu,f,cst.mu=TRUE,expo.lamb=TRUE, dt=1e3)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.