simulate | R Documentation |
Simulates the evolution of the ecological trait through time by computing the trait value at the next generation as a function of the selection gradient computed at the present generation.
simulate(
xstart,
ntimes,
pars,
init,
mu = 0.01,
sigma = 0.1,
tol = 1e-04,
dodge = 0.001,
burnin = 0,
branch = 1
)
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 four 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 |
tol |
The tolerance when assessing if the selection gradient is close enough to zero and an equilibrium has been reached |
dodge |
How much to displace each morph from the branching point once branching has occurred |
burnin |
The number of time steps in the burn-in period |
branch |
Integer indicating whether and how branching occurs (see
|
This function simulates evolution in three phases: (1) the burn-in phase (where only one habitat and one resource are available), (2) monomorphic evolution (in two habitats and with two resources) and (3) dimorphic evolution once a branching point is reached (if it is ever reached).
At each time step the equilibrium population sizes must be solved
numerically, using the values in init
as starting points. This is
done using find_equilibrium_burnin
, find_equilibrium
or
find_equilibrium_di
, depending on the phase we are in. Before
branching there are only two population sizes (one for each habitat) and so
only the two first values in init
are used. After branching, all
values are used, the first two corresponding to habitat 1 and 2,
respectively, for the first morph (the one with a more negative trait value),
and the last two for habitat 1 and 2, respectively, for the second morph.
Parameters mu
and sigma
modulate the response to selection
at each time step (and so the rate of evolution). mu
should be
interpreted as the probability that the trait mutates in a single time
step (mu = 0.01
would be reasonable for a trait encoded by 100 loci
and with a 0.0001 mutation rate per locus). sigma
is, strictly
speaking, the standard deviation of the distribution of mutational effects.
An equilibrium is reached when the selection gradient falls within tol
units
around zero. If this equilibrium is a branching point (assessed using
is_stable
) then the dimorphic phase starts and the two morphs are
displaced by dodge
units before undergoing separate evolutionary
trajectories with two different selection gradients (but still influencing
each other).
A tibble containing the trait values in the two morphs at each time point (with burn-in time points returned as negative integers).
The trait values of the two morphs are equal before a branching point has been reached.
simulate_burnin
, simulate_mono
, simulate_di
,
is_stable
pars <- get_default_pars()
simulate(-1, ntimes = 10, pars, init = rep(1000, 4))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.