Learn R Programming

PBD (version 1.4)

pbd_sim: Function to simulate the protracted speciation process

Description

Simulating the protracted speciation process using the Doob-Gillespie algorithm. This function differs from pbd_sim_cpp that 1) it does not require that the speciation-initiation rate is the same for good and incipient species, and 2) that it simulates the exact protracted speciation process, and not the approximation made by the coalescent point process. This function provides also the conversion to the approximation as output.

Usage

pbd_sim(
   pars,
   age,
   soc = 2,
   plotit = FALSE,
   limitsize = Inf
)

Arguments

pars
Vector of parameters: pars[1] corresponds to b_1, the speciation-initiation rate of good species pars[2] corresponds to la_1, the speciation-completion rate pars[3] corresponds to b_2, the speciation-initiation rate of incipient species pars[4] corresponds to mu_1, the extinction rate of good species pars[5] corresponds to mu_2, the extinction rate of incipient species
age
Sets the age for the simulation
soc
Sets whether this age is the stem (1) or crown (2) age
plotit
Sets whether the various trees produced by the function should be plotted or not
limitsize
Sets a maximum to the number of incipient + good species that are created during the simulation; if exceeded, the simulation is aborted and removed.

Value

out
A list with the following elements: tree is the tree of extant species in phylo format stree_random is a tree with one random sample per species in phylo format stree_oldest is a tree with the oldest sample per species in phylo format stree_youngest is a tree with the youngest sample per species in phylo format L is a matrix of all events in the simulation where - the first column is the incipient-level label of a species - the second column is the incipient-level label of the parent of the species - the third column is the time at which a species is born as incipient species - the fourth column is the time of speciation-completion of the species If the fourth element equals -1, then the species is still incipient. - the fifth column is the time of extinction of the species If the fifth element equals -1, then the species is still extant. - The sixth column is the species-level label of the species sL_random is a matrix like L but for stree_random sL_oldest is a matrix like L but for stree_oldest sL_youngest is a matrix like L but for stree_youngest igtree.extinct is the tree in simmap format with incipient and good flags and including extinct species igtree.extant is the tree in simmap format with incipient and good flags without extinct species recontree is the reconstructed tree in phylo format, reconstructed using the approximation in Lambert et al. 2014 reconL is the matrix corresponding to recontree L0 is a matrix where the crown age is at 0; for internal use only

See Also

pbd_sim_cpp