View source: R/posteriorpredictive_helpr.R
sim_history | R Documentation |
Simulate history of discrete-character changes over a bifurcation tree conditional or unconditional on the tip states
sim_history( tree, Q, Q_ages = NULL, root_freq = NULL, nsim = 1L, conditional = F, trait = NULL )
tree |
A bifurcation tree of class "phylo" |
Q |
An instantaneous-rate matrix (or a list of matrices for a piecewise constant geographic model) characterizes the CTMC |
Q_ages |
Boundaries of time intervals for a piecewise constant geographic model (NULL means a constant model) |
root_freq |
The vector state frequencies at the root of the tree (that we will draw the root state from); if NULL then it's uniform |
nsim |
Number of simulations to perform |
conditional |
Whether condition on the observed states at the tip (i.e., stochastic mapping) or not (i.e., forward simulation) |
trait |
Name of the discrete trait used in the tree file (e.g., "states") |
A phylo and simmap object (or a multiPhylo and multiSimmap object when nsim > 1) that contains the simulated full history
tree <- ape::rtree(7) Q <- matrix(c(-1, 1, 1, -1), ncol = 2, byrow = TRUE) root_freq <- setNames(rep(0.5, 2), c("A", "B")) one_history <- sim_history(tree, Q, root_freq = root_freq, conditional = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.