X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=R%2Fbirthdeath.R;h=b4a25e17505aa835af535fd694c80ecabd609b73;hb=2741f6e9f61e33c7b499f27c47604606d08f4bea;hp=469eef5d4089de159da3edad877904d70ccc0584;hpb=c827059eeafc8cbe41c812b26979543ab287803e;p=ape.git diff --git a/R/birthdeath.R b/R/birthdeath.R index 469eef5..b4a25e1 100644 --- a/R/birthdeath.R +++ b/R/birthdeath.R @@ -1,4 +1,4 @@ -## birthdeath.R (2007-10-30) +## birthdeath.R (2010-10-17) ## Estimation of Speciation and Extinction Rates ## with Birth-Death Models @@ -6,17 +6,18 @@ ## 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]) @@ -80,11 +81,11 @@ print.birthdeath <- function(x, ...) 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)