View source: R/simulate_mono.R
simulate_mono | R Documentation |
Simulates trait evolution in a monomorphic population.
simulate_mono(
xstart,
ntimes,
pars,
init,
mu = 0.01,
sigma = 0.1,
branch = 1,
tol = 1e-04
)
xstart |
Starting trait value |
ntimes |
The number of time steps to simulate for |
pars |
An unevaluated parameter-list (e.g. as returned by
|
init |
A vector of two starting values for solving of the demographic equilibrium |
mu |
The mutation rate of the trait (per time step) |
sigma |
The (standard deviation of) mutational step size upon mutation |
branch |
Integer indicating whether branching may occur and how
convergence to the equilibrium is assessed: 0, branching is not allowed;
1, branching is allowed and equilibrium is reached when the selection
gradient is close enough to zero; 2, branching happens when two mutants away
by |
tol |
The tolerance when assessing if the selection gradient is close
enough to zero and an equilibrium has been reached (if |
See ?simulate
.
There are two ways to assess whether a branching point has been reached.
One (branch = 1
) is to evaluate the curvature of the fitness function
when the selection gradient becomes zero (i.e. at a singularity, see
?is_stable
). Another way (branch = 2
) is to evaluate the
mutual invasibility of the current resident and a mutant that is some
mutationally reasonable phenotypic distance away (e.g. one mutational
standard deviation sigma
away). If each of the two (when taken as
a resident) can be invaded by the other (taken as a mutant, see
?get_lambda
) then a stable polymorphism can persist and we assume
that branching occurs. In practice, the branching point may be reached
quicker with branch = 2
as it does not need to wait for the gradient
to completely converge to zero (within the limits imposed by tol
,
which can also be rather arbitrary).
A tibble containing the trait value of the population at each time point
The argument branch
will be reverted to 1 if the selection
gradient reaches the value of exactly zero, even if branch = 2
was
set in the function call (this is to ensure symmetry of the branching event).
find_equilibrium
, get_gradient
, get_lambda
pars <- get_default_pars()
simulate_mono(-1, 10, pars, init = rep(1000, 2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.