Learn R Programming

phytools (version 0.2-40)

sim.history: Simulate stochastic character history under some model

Description

This function simulates a stochastic character history for a discretely valued character trait on the tree. The resultant tree is stored as a modified "phylo" object in stochastic character map (e.g., make.simmap) format.

Usage

sim.history(tree, Q, anc=NULL, nsim=1)

Arguments

tree
a phylogenetic tree as an object of class "phylo".
Q
a matrix containing the instantaneous transition rates between states.
anc
an optional value for the state at the root node; if NULL, a random state will be assigned.
nsim
number of simulations.

Value

  • a modified phylogenetic tree of class "phylo" (or a modified "multiPhylo" object, for nsim > 1) with the following additional elements:
  • mapsa list of named vectors containing the times spent in each state on each branch, in the order in which they occur.
  • mapped.edgea matrix containing the total time spent in each state along each edge of the tree.
  • statesa vector containing the tip states.
  • node.statesa matrix containing the states at internal & terminal nodes (according to the dimensions of edge).

See Also

make.simmap, read.simmap, plotSimmap, sim.rates