View source: R/trait.process.R
trait.process | R Documentation |
Different trait processes implemented in treats.
trait.process(x0, edge.length, ...)
x0 |
The previous state. This can be a single value (unidimensional process) or more (multidimensional processes). |
edge.length |
The branch length (default must be 1). This is always a single value. |
... |
Any optional argument for the specific process (see details). |
The different trait processes implemented in treats are:
BM.process A Brownian motion process (uni or multidimensional). This function is based on mvrnorm
.
This process can take following optional arguments:
Sigma
a positive-definite symmetric matrix specifying the covariance matrix of the variables (default is diag(length(x0))
).
...
any named additional argument to be passed to mvrnorm
.
discrete.process This process can take following optional arguments:
transitions
a positive-definite squared transition matrix. If left missing, a 2 states equal rates matrix is used.
Note that for this process, 0 corresponds to state 1, 1 corresponds to state 2, etc... The current version of this process does not allow other discrete traits notation (but future versions will!).
OU.process A Ornstein-Uhlenbeck process (uni or multidimensional). This function is based on mvrnorm
.
This process can take following optional arguments:
Sigma
the traits variance/covariance (default is diag(length(x0))
).
alpha
the alpha parameter (default = is 1
).
optimum
the theta parameter (default = is 0
).
...
any named additional argument to be passed to mvrnorm
.
no.process An non-process unidimensional function. This function generates a trait value not depending on the branch length nor the previous state This process can take following optional arguments:
fun
a random number function (default is rnorm
).
...
any named additional argument to be passed to fun
.
multi.peak.process A Ornstein-Uhlenbeck process (uni or multidimensional) with multiple optimal values. This function is based on mvrnorm
.
This process can take following optional arguments:
Sigma
the traits variance/covariance (default is diag(length(x0))
).
alpha
the alpha parameter (default = is 1
).
peaks
the multiple optimal values to be attracted to (default = is 0
). This can be a numeric
vector to be applied to all the values of x0
or a list
of the same length as x0
for different multiple optimums for each x0
.
...
any named additional argument to be passed to mvrnorm
.
repulsion.process An unidimensional Brownian Motion process that generates a trait value not overlapping with the other living taxa ancestral values. This function is based on rnorm
.
This process can take following optional arguments:
sd
the normal distribution standard deviation.
repulsion
the minimal distance requested between trait values.
max.try
the maximum number of values to draw (if the repulsion value is to hard to achieve).
trait.values
LEAVE AS NULL
(it designates the trait value table from the birth death process and is handled internally by treats
).
lineage
LEAVE AS NULL
(it designates the lineage object from the birth death process and is handled internally by treats
).
trait
LEAVE AS NULL
(it which trait to use and is analysed an is handled internally by treats
).
More details about the trait.process
functions is explained in the treats
manual: http://tguillerme.github.io/treats.
Returns one or more "numeric"
value(s).
Thomas Guillerme
treats
make.traits
## NOTE: You can visualise most process by making them
## into a "treats" "traits" object using make.traits():
## The Brownian motion process
BM.process(x0 = 0)
plot(make.traits(process = BM.process))
## A covariance matrix between 3 traits
varcovar_matrix <- matrix(c(1/3,1/3,1/3,1/3,2/3,0,1/3,0,2/3), ncol = 3)
BM.process(x0 = c(0,0,0), Sigma = varcovar_matrix)
## The Ornstein-Uhlenbeck process
OU.process(x0 = 0)
plot(make.traits(process = OU.process))
## No process
no.process()
plot(make.traits(process = no.process))
## Multi peaks with peaks at the values 1, 5 and 10
multi.peak.process(peaks = c(1, 5, 10))
plot(make.traits(multi.peak.process, process.args = list(peaks = c(1, 5, 10))))
## Repulsion process
repulsion.process(x0 = 0, repulsion = 1)
plot(make.traits(repulsion.process, process.args = list(repulsion = 5)))
## Discrete trait process
## Generating a stepwise transition matrix for 3 states (with an overal random transition rate)
stepwise_matrix <- transition.matrix(type = "stepwise", states = 3)
## Generatin and plotting the the trait
plot(make.traits(discrete.process, process.args = list(transitions = stepwise_matrix)))
##
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.