Learn R Programming

phytools (version 0.3-72.1)

rerootingMethod: Get marginal ancestral state reconstructions by re-rooting

Description

This function uses the re-rooting method of Yang et al. (1995) to get the marginal ancestral state estimates for each internal node of the tree using likelihood. This method get the conditional scaled likelihoods for the root node (which is the same as the marginal ancestral state reconstruction for that node) and successively moves the root to each node in the tree. The function can also return the posterior probabilities for the tip nodes of the tree.

Usage

rerootingMethod(tree, x, model=c("ER","SYM"), ...)

Arguments

tree
an object of class "phylo".
x
a vector of tip values for species, or a matrix containing the prior probability that the tip is in each state. If x is a vector, then names(x) should be the species names. If x is a matrix of prior probabilities, th
model
any revsersible model. model=c("ER","SYM") recommended.
...
optional arguments. Presently the logical argument tips. If tips=TRUE, then the function will also compute the empirical Bayes posterior probabilities of the tips following Yang (2006).

Value

  • A list containing the following elements:
  • loglikthe log-likelihood.
  • Qthe fitted transition matrix between states.
  • marginal.ancthe marginal ancestral state reconstructions for each node (and, optionally, each tip).

Details

This function calls code modified from ace in the (Paradis et al. 2004) internally in the calculation of normalized conditional likelihoods.

See Also

ace, make.simmap