3 \title{Continuous Character Simulation}
5 rTraitCont(phy, model = "BM", sigma = 0.1, alpha = 1,
6 theta = 0, ancestor = FALSE, root.value = 0)
9 \item{phy}{an object of class \code{"phylo"}.}
10 \item{model}{a character (either \code{"BM"} or \code{"OU"}) or a
11 function specifying the model (see details).}
12 \item{sigma}{a numeric vector giving the standard-deviation of the
13 random component for each branch (can be a single value).}
14 \item{alpha}{if \code{model = "OU"}, a numeric vector giving the
15 strength of the selective constraint for each branch (can be a
17 \item{theta}{if \code{model = "OU"}, a numeric vector giving the
18 optimum for each branch (can be a single value).}
19 \item{ancestor}{a logical value specifying whether to return the
20 values at the nodes as well (by default, only the values at the tips
22 \item{root.value}{a numeric giving the value at the root.}
25 This function simulates the evolution of a continuous character along a
26 phylogeny. The calculation is done recursively from the root. See
27 Paradis (2006, p. 151) for a brief introduction.
30 There are three possibilities to specify \code{model}:
33 \item{\code{"BM"}:}{a Browian motion model is used. If the arguments
34 \code{sigma} has more than one value, its length must be equal to the
35 the branches of the tree. This allows to specify a model with variable
36 rates of evolution. You must be careful that branch numbering is done
37 with the tree in ``pruningwise'' order: to see the order of the branches
38 you can use: \code{tr <- reorder(tr, "p"); plor(tr); edgelabels()}.
39 The arguments \code{alpha} and \code{theta} are ignored.}
41 \item{\code{"OU"}:}{an Ornstein-Uhlenbeck model is used. The above
42 indexing rule is used for the three parameters \code{sigma},
43 \code{alpha}, and \code{theta}. This may be more interesting for the
44 last one to model varying phenotypic optima. Be careful that large
45 values of \code{alpha} may give unrealistic output.}
47 \item{A function:}{it must be of the form \code{foo(x, l)} where
48 \code{x} is the trait of the ancestor and \code{l} is the branch
49 length. It must return the value of the descendant. The arguments
50 \code{sigma}, \code{alpha}, and \code{theta} are ignored.}
53 Currently, the OU model is a bit difficult to tune. Hopefully, this
54 may be improved in the future.
57 A numeric vector with names taken from the tip labels of
58 \code{phy}. If \code{ancestor = TRUE}, the node labels are used if
59 present, otherwise, ``Node1'', ``Node2'', etc.
62 Paradis, E. (2006) \emph{Analyses of Phylogenetics and Evolution with
63 R.} New York: Springer.
65 \author{Emmanuel Paradis}
67 \code{\link{rTraitDisc}}, \code{\link{ace}}
71 rTraitCont(bird.orders) # BM with sigma = 0.1
72 ### OU model with two optima:
73 tr <- reorder(bird.orders, "p")
76 theta <- rep(0, Nedge(tr))
77 theta[c(1:4, 15:16, 23:24)] <- 2
78 ## sensitive to 'alpha' and 'sigma':
79 rTraitCont(tr, "OU", theta = theta, alpha=.1, sigma=.01)
80 ### an imaginary model with stasis 0.5 time unit after a node, then
81 ### BM evolution with sigma = 0.1:
82 foo <- function(x, l) {
83 if (l <= 0.5) return(x)
84 x + (l - 0.5)*rnorm(1, 0, 0.1)
86 tr <- rcoal(20, br = runif)
87 rTraitCont(tr, foo, ancestor = TRUE)
88 ### a cumulative Poisson process:
89 bar <- function(x, l) x + rpois(1, l)
90 (x <- rTraitCont(tr, bar, ancestor = TRUE))
91 plot(tr, show.tip.label = FALSE)