doSimulation | R Documentation |
The function doSimulation
evolves continuous characters under a discrete time process.
These functions are mainly used as internal components, generating simulations
within ABC analyses using the doRun
functions. See Note below.
doSimulation(
phy = NULL,
intrinsicFn,
extrinsicFn,
startingValues,
intrinsicValues,
extrinsicValues,
generation.time = 1000,
TreeYears = max(branching.times(phy)) * 1e+06,
timeStep = NULL,
returnAll = FALSE,
taxonDF = NULL,
checkTimeStep = TRUE
)
phy |
A phylogenetic tree, in package |
intrinsicFn |
Name of (previously-defined) function that governs how traits evolve within a lineage, regardless of the trait values of other taxa. |
extrinsicFn |
Name of (previously-defined) function that governs how traits evolve within a lineage, based on their own ('internal') trait vlaue and the trait values of other taxa. |
startingValues |
State at the root. |
intrinsicValues |
Vector of values corresponding to the parameters of the intrinsic model. |
extrinsicValues |
Vector of values corresponding to the parameters of the extrinsic model. |
generation.time |
The number of years per generation.
This sets the coarseness of the simulation; if it's set to 1000,
for example, the population's trait values change every 1000
calendar years. Note that this is in calendar years (see description
for argument |
TreeYears |
The amount of calendar time from the root
to the furthest tip. Most trees in macroevolutionary studies are dated with
branch lengths in units of millions of years, and thus the
default for this argument is |
timeStep |
This value corresponds to the length
of intervals between discrete evolutionary events ('generations')
simulated along branches, relative to a rescaled tree
where the root to furthest tip distance is 1. For example,
|
returnAll |
If |
taxonDF |
A data.frame containing data on nodes (both
tips and internal nodes) output by various internal functions.
Can be supplied as input to spead up repeated calculations, but by default is
|
checkTimeStep |
If |
The phylogenetic tree used is rescaled such that the
distance from the root to the furthest tip is rescaled to equal 1 time-unit,
and it is this rescaled edge lengths to with arguments
timeStep
refers to. Typically, this will be determined though
as a ratio of TreeYears
(which is the number
of calendar years constituing the root-to-furthest-tip distance, and
is determined by default as if the user had supplied
a tree with edge lengths in time-units of 1 time-unit = 1 million years), and
generation.time
, which gives the length of
timeSteps
in calendar years (e.g. generation.time = 1000
means
an evolutionary change in trait values every 1000 years).
Note that the real number of trait change events simulated may be less
less, because simulations start over at each branching
node, but intervals between changes should be so fine that this
should be negligible (related, the results should be
independent of your choice for generation.time
or timeStep
).
We recommend that the effective timeStep
should be
as short as is computationally possible.
SaveRealParams
is useful for tracking the real true values if simulating
data to test the performance of ABC analyses.
It is not useful for ABC analyses of empirical data.
If returnAll = FALSE
(the default),
this function returns a data frame of species character (tip)
values in the tree, as a single column named 'states'
with rownames reflecting the taxon names given in
phy$tip.label
.
If returnAll = TRUE
, the raw data.frame
from the simulation will instead be returned.
The simulateWithPriors
functions are effectively
the engine that powers the doRun
functions, while the doSimulation
functions are
the pistons within the simulateWithPriors
engine.
In general, most users will just drive the car - they will just
use doRun
, but some users may
want to use simulateWithPriors
or
doSimulation
functions to do various simulations.
Brian O'Meara and Barb Banbury
set.seed(1)
tree <- rcoal(20)
# get realistic edge lengths
tree$edge.length <- tree$edge.length*20
#Simple Brownian motion
char <- doSimulation(
phy = tree,
generation.time = 100000,
intrinsicFn = brownianIntrinsic,
extrinsicFn = nullExtrinsic,
startingValues = c(10), #root state
intrinsicValues = c(0.01),
extrinsicValues = c(0))
#Character displacement model with minimum bound
char <- doSimulation(
phy = tree,
generation.time = 100000,
intrinsicFn = boundaryMinIntrinsic,
extrinsicFn = ExponentiallyDecayingPushExtrinsic,
startingValues = c(10), #root state
intrinsicValues = c(0.05, 10, 0.01),
extrinsicValues = c(0, .1, .25))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.