simulate_mono: Simulate monomorphic evolution

View source: R/simulate_mono.R

simulate_monoR Documentation

Simulate monomorphic evolution

Description

Simulates trait evolution in a monomorphic population.

Usage

simulate_mono(
  xstart,
  ntimes,
  pars,
  init,
  mu = 0.01,
  sigma = 0.1,
  branch = 1,
  tol = 1e-04
)

Arguments

xstart

Starting trait value

ntimes

The number of time steps to simulate for

pars

An unevaluated parameter-list (e.g. as returned by get_default_pars)

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 sigma units can mutually invade each other.

tol

The tolerance when assessing if the selection gradient is close enough to zero and an equilibrium has been reached (if branch = 1).

Details

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).

Value

A tibble containing the trait value of the population at each time point

Note

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).

See Also

find_equilibrium, get_gradient, get_lambda

Examples


pars <- get_default_pars()
simulate_mono(-1, 10, pars, init = rep(1000, 2))


rscherrer/speciomx documentation built on March 28, 2023, 8:49 p.m.