trait.process {treats} | R Documentation |
Trait processes
Description
Different trait processes implemented in treats.
Usage
trait.process(x0, edge.length, ...)
Arguments
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). |
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 isdiag(length(x0))
). -
...
any named additional argument to be passed tomvrnorm
.
-
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 isdiag(length(x0))
). -
alpha
the alpha parameter (default = is1
). -
optimum
the theta parameter (default = is0
). -
...
any named additional argument to be passed tomvrnorm
.
-
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 isrnorm
). -
...
any named additional argument to be passed tofun
.
-
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 isdiag(length(x0))
). -
alpha
the alpha parameter (default = is1
). -
peaks
the multiple optimal values to be attracted to (default = is0
). This can be anumeric
vector to be applied to all the values ofx0
or alist
of the same length asx0
for different multiple optimums for eachx0
. -
...
any named additional argument to be passed tomvrnorm
.
-
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 ASNULL
(it designates the trait value table from the birth death process and is handled internally bytreats
). -
lineage
LEAVE ASNULL
(it designates the lineage object from the birth death process and is handled internally bytreats
). -
trait
LEAVE ASNULL
(it which trait to use and is analysed an is handled internally bytreats
).
-
More details about the trait.process
functions is explained in the treats
manual: http://tguillerme.github.io/treats.
Value
Returns one or more "numeric"
value(s).
Author(s)
Thomas Guillerme
See Also
Examples
## 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)))