5 \title{Probability Density Under Birth--Death Models}
7 These functions compute the probability density under some
8 birth--death models, that is the probability of obtaining \emph{x}
9 species after a time \emph{t} giving how speciation and extinction
10 probabilities vary through time (these may be constant, or even equal
11 to zero for extinction).
14 dyule(x, lambda = 0.1, t = 1, log = FALSE)
15 dbd(x, lambda, mu, t, conditional = FALSE, log = FALSE)
16 dbdTime(x, birth, death, t, conditional = FALSE,
17 BIRTH = NULL, DEATH = NULL, fast = FALSE)
20 \item{x}{a numeric vector of species numbers (see Details).}
21 \item{lambda}{a numerical value giving the probability of speciation;
22 can be a vector with several values for \code{dyule}.}
23 \item{mu}{id. for extinction.}
24 \item{t}{id. for the time(s).}
25 \item{log}{a logical value specifying whether the probabilities should
26 be returned log-transformed; the default is \code{FALSE}.}
27 \item{conditional}{a logical specifying whether the probabilities
28 should be computed conditional under the assumption of no extinction
30 \item{birth, death}{a (vectorized) function specifying how the
31 speciation or extinction probability changes through time (see
32 \code{\link{yule.time}} and below).}
33 \item{BIRTH, DEATH}{a (vectorized) function giving the primitive
34 of \code{birth} or \code{death}.}
35 \item{fast}{a logical value specifying whether to use faster
36 integration (see \code{\link{bd.time}}).}
39 These three functions compute the probabilities to observe \code{x}
40 species starting from a single one after time \code{t} (assumed to be
41 continuous). The first function is a short-cut for the second one with
42 \code{mu = 0} and with default values for the two other arguments.
43 \code{dbdTime} is for time-varying \code{lambda} and \code{mu}
44 specified as \R functions.
46 Only \code{dyule} is vectorized simultaneously on its three arguments
47 \code{x}, \code{lambda}, and \code{t}, according to \R's rules of
48 recycling arguments. The two others are vectorized only on \code{x};
49 the other arguments are eventually shortened with a warning if
52 The returned value is, logically, zero for values of \code{x} out of
53 range, i.e., negative or zero for \code{dyule} or if \code{conditional
54 = TRUE}. However, it is not checked if the values of \code{x} are
55 positive non-integers and the probabilities are computed and returned.
57 The details on the form of the arguments \code{birth}, \code{death},
58 \code{BIRTH}, \code{DEATH}, and \code{fast} can be found in the links
62 If you use these functions to calculate a likelihood function, it is
63 strongly recommended to compute the log-likelihood with, for instance
64 in the case of a Yule process, \code{sum(dyule( , log = TRUE))} (see
71 Kendall, D. G. (1948) On the generalized ``birth-and-death''
72 process. \emph{Annals of Mathematical Statistics}, \bold{19}, 1--15.
74 \author{Emmanuel Paradis}
76 \code{\link{bd.time}}, \code{\link{yule.time}}
80 plot(x, dyule(x), type = "h", main = "Density of the Yule process")
81 text(7, 0.85, expression(list(lambda == 0.1, t == 1)))
83 y <- dbd(x, 0.1, 0.05, 10)
84 z <- dbd(x, 0.1, 0.05, 10, conditional = TRUE)
87 barplot(d, beside = TRUE, ylab = "Density", xlab = "Number of species",
88 legend = c("unconditional", "conditional on\nno extinction"),
89 args.legend = list(bty = "n"))
90 title("Density of the birth-death process")
91 text(17, 0.4, expression(list(lambda == 0.1, mu == 0.05, t == 10)))
94 ### generate 1000 values from a Yule process with lambda = 0.05
95 x <- replicate(1e3, Ntip(rlineage(0.05, 0)))
97 ### the correct way to calculate the log-likelihood...:
98 sum(dyule(x, 0.05, 50, log = TRUE))
100 ### ... and the wrong way:
101 log(prod(dyule(x, 0.05, 50)))
103 ### a third, less preferred, way:
104 sum(log(dyule(x, 0.05, 50)))