rTraitCont: Continuous Character Simulation

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

This function simulates the evolution of a continuous character along a phylogeny. The calculation is done recursively from the root. See Paradis (2006, p. 151) for a brief introduction.

Usage

1
2
rTraitCont(phy, model = "BM", sigma = 0.1, alpha = 1, theta = 0,
           ancestor = FALSE, root.value = 0, linear = TRUE)

Arguments

phy

an object of class "phylo".

model

a character (either "BM" or "OU") or a function specifying the model (see details).

sigma

a numeric vector giving the standard-deviation of the random component for each branch (can be a single value).

alpha

if model = "OU", a numeric vector giving the strength of the selective constraint for each branch (can be a single value).

theta

if model = "OU", a numeric vector giving the optimum for each branch (can be a single value).

ancestor

a logical value specifying whether to return the values at the nodes as well (by default, only the values at the tips are returned).

root.value

a numeric giving the value at the root.

linear

a logical indicating which parameterisation of the OU model to use (see details).

Details

There are three possibilities to specify model:

Value

A numeric vector with names taken from the tip labels of phy. If ancestor = TRUE, the node labels are used if present, otherwise, “Node1”, “Node2”, etc.

Author(s)

Emmanuel Paradis

References

Paradis, E. (2006) Analyses of Phylogenetics and Evolution with R. New York: Springer.

See Also

rTraitDisc, ace

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
data(bird.orders)
rTraitCont(bird.orders) # BM with sigma = 0.1
### OU model with two optima:
tr <- reorder(bird.orders, "p")
plot(tr)
edgelabels()
theta <- rep(0, Nedge(tr))
theta[c(1:4, 15:16, 23:24)] <- 2
## sensitive to 'alpha' and 'sigma':
rTraitCont(tr, "OU", theta = theta, alpha=.1, sigma=.01)
### an imaginary model with stasis 0.5 time unit after a node, then
### BM evolution with sigma = 0.1:
foo <- function(x, l) {
    if (l <= 0.5) return(x)
    x + (l - 0.5)*rnorm(1, 0, 0.1)
}
tr <- rcoal(20, br = runif)
rTraitCont(tr, foo, ancestor = TRUE)
### a cumulative Poisson process:
bar <- function(x, l) x + rpois(1, l)
(x <- rTraitCont(tr, bar, ancestor = TRUE))
plot(tr, show.tip.label = FALSE)
Y <- x[1:20]
A <- x[-(1:20)]
nodelabels(A)
tiplabels(Y)

gjuggler/ape documentation built on May 17, 2019, 6:03 a.m.