modifiers {treats} | R Documentation |
Modifiers
Description
Different modifiers for the birth death process implemented in treats.
Usage
modifiers(bd.params = NULL, lineage = NULL, trait.values = NULL,
modify.fun = NULL)
Arguments
bd.params |
A named list of birth death parameters (see details). |
lineage |
A named list containing the lineage data (see details). |
trait.values |
A matrix containing the trait values (see details). |
modify.fun |
A list of internals functions that can modified by |
Details
bd.params
can be either a named list of parameter values (e.g. list("extinction" = 0, "speciation" = 1)
) but it is typically handled internally from a "treats"
"bd.params"
object.
modifiers
are functions passed to the birth death process in treats
to either generate the branch length (named branch.length
and similar) or to decide whether to speciate or go extinct (named speciation
and similar).
For user defined functions, the modifiers
must have at least the arguments described above. For safety, we suggest setting these arguments to NULL
.
The pre-build modifiers
in the treats
package are (so far):
-
branch.length
the simple branch length generator that randomly gets a numeric value drawn from the exponential distribution (rexp
) with a rate equal to the number of taxa (lineage$n * bd.params$speciation + bd.params$extinction
). -
branch.length.trait
a modification of thebranch.length
modifier
where the resulting branch length is changed bymodify.fun$modify
if the parent trait(s) meet the conditionmodify.fun$condition
. -
selection
a function returning a randomly sampled integer among the number of taxa available. -
speciation
a function returningTRUE
(speciation) if a random uniform number (runif
) is smaller than the ratio of speciation by speciation and extinction (bd.params$speciation / (bd.params$speciation) + bd.params$extinction
). If it's bigger, the function returnsFALSE
(exinction). -
speciation.trait
a modification of thespeciation
modifier
where the random uniform number is changed bymodify.fun$modify
if the parent trait(s) meet the conditionmodify.fun$condition
.
More details about the modifiers
functions is explained in the treats
manual: http://tguillerme.github.io/treats.
Value
These functions returns either "numeric"
or "logical"
values to be passed to make.modifiers
and treats
.
Author(s)
Thomas Guillerme
See Also
Examples
## These functions should be fed to the make.modifiers function to create
## modifiers for treats objects. For example, the following sets specifies that
## the branch length should be generated using the branch.length.trait function
## the selection using the selection function and the speciation using the
## speciation.trait function:
my_modifiers <- make.modifiers(branch.length = branch.length.trait,
selection = selection,
speciation = speciation.trait)
## Creating a treats simulation using these modifiers
treats(stop.rule = list(max.taxa = 20),
traits = make.traits(),
modifiers = my_modifiers)