]> git.donarmstrong.com Git - ape.git/blob - man/yule.time.Rd
91cbe04f483c99e1381f48caabcafcd24f60ba8e
[ape.git] / man / yule.time.Rd
1 \name{yule.time}
2 \alias{yule.time}
3 \title{Fits the Time-Dependent Yule Model}
4 \usage{
5 yule.time(phy, birth, BIRTH = NULL, root.time = 0, opti = "nlm", start = 0.01)
6 }
7 \arguments{
8   \item{phy}{an object of class \code{"phylo"}.}
9   \item{birth}{a (vectorized) function specifying how the birth
10     (speciation) probability changes through time (see details).}
11   \item{BIRTH}{a (vectorized) function giving the primitive of
12     \code{birth}.}
13   \item{root.time}{a numeric value giving the time of the root node
14     (time is measured from the past towards the present).}
15   \item{opti}{a character string giving the function used for
16     optimisation of the likelihood function. Three choices are possible:
17     \code{"nlm"}, \code{"nlminb"}, or \code{"optim"}, or any unambiguous
18     abbreviation of these.}
19   \item{start}{the initial values used in the optimisation.}
20 }
21 \description{
22   This function fits by maximum likelihood the time-dependent Yule
23   model. The time is measured from the past (\code{root.time}) to the
24   present.
25 }
26 \details{
27   The model fitted is a straightforward extension of the Yule model with
28   covariates (see \code{\link{yule.cov}}). Rather than having
29   heterogeneity among lineages, the speciation probability is the same
30   for all lineages at a given time, but can change through time.
31
32   The function \code{birth} \emph{must} meet these two requirements: (i)
33   the parameters to be estimated are the formal arguments; (ii) time is
34   named \code{t} in the body of the function. However, this is the
35   opposite for the primitive \code{BIRTH}: \code{t} is the formal
36   argument, and the parameters are used in its body. See the examples.
37
38   It is recommended to use \code{BIRTH} if possible, and required if
39   speciation probability is constant on some time interval. If this
40   primitive cannot be provided, a numerical integration is done with
41   \code{\link[stats]{integrate}}.
42
43   The standard-errors of the parameters are computed with the Hessian of
44   the log-likelihood function.
45 }
46 \value{
47   An object of class \code{"yule"} (see \code{\link{yule}}).
48 }
49 \author{Emmanuel Paradis}
50 \seealso{
51   \code{\link{branching.times}}, \code{\link{ltt.plot}},
52   \code{\link{birthdeath}}, \code{\link{yule}}, \code{\link{yule.cov}},
53   \code{\link{bd.time}}
54 }
55 \examples{
56 ### define two models...
57 birth.logis <- function(a, b) 1/(1 + exp(-a*t - b)) # logistic
58 birth.step <- function(l1, l2, Tcl) { # 2 rates with one break-point
59     ans <- rep(l1, length(t))
60     ans[t > Tcl] <- l2
61     ans
62 }
63 ### ... and their primitives:
64 BIRTH.logis <- function(t) log(exp(-a*t) + exp(b))/a + t
65 BIRTH.step <- function(t)
66 {
67     out <- numeric(length(t))
68     sel <- t <= Tcl
69     if (any(sel)) out[sel] <- t[sel] * l1
70     if (any(!sel)) out[!sel] <- Tcl * l1 + (t[!sel] - Tcl) * l2
71     out
72 }
73 data(bird.families)
74 ### fit both models:
75 yule.time(bird.families, birth.logis)
76 yule.time(bird.families, birth.logis, BIRTH.logis) # same but faster
77 \dontrun{yule.time(bird.families, birth.step)}  # fails
78 yule.time(bird.families, birth.step, BIRTH.step,
79           opti = "nlminb", start = c(.01, .01, 100))
80 }
81 \keyword{models}