-## birthdeath.R (2007-10-30)
+## birthdeath.R (2010-10-17)
## Estimation of Speciation and Extinction Rates
## with Birth-Death Models
## birthdeath: standard model
## bd.ext: extended version
-## Copyright 2002-2007 Emmanuel Paradis
+## Copyright 2002-2010 Emmanuel Paradis
## This file is part of the R-package `ape'.
## See the file ../COPYING for licensing issues.
birthdeath <- function(phy)
{
- if (class(phy) != "phylo") stop('object "phy" is not of class "phylo"')
+ if (!inherits(phy, "phylo")) stop('object "phy" is not of class "phylo"')
N <- length(phy$tip.label)
x <- c(NA, branching.times(phy))
dev <- function(a, r) {
+ if (r <= 0) return(1e50)
-2 * (lfactorial(N - 1)
+ (N - 2) * log(r)
+ r * sum(x[3:N])
bd.ext <- function(phy, S)
{
- if (class(phy) != "phylo") stop('object "phy" is not of class "phylo"')
+ if (!inherits(phy, "phylo")) stop('object "phy" is not of class "phylo"')
if (!is.null(names(S))) {
if (all(names(S) %in% phy$tip.label)) S <- S[phy$tip.label]
- else warning('the names of argument "S" and the names of the tip labels
-did not match: the former were ignored in the analysis.')
+ else warning('the names of argument "S" and the tip labels
+did not match: the former were ignored.')
}
N <- length(S)
x <- branching.times(phy)