Learn R Programming

Rphylopars (version 0.2.9)

anc.recon: Ultra-fast maximum likelihood ancestral state reconstruction

Description

This function performs ancestral state reconstruction using a fast algorithm based on Ho and Ane (2014). Contrary to fastAnc, which reroots the tree at each internal node and recalculates the root state for each tree, this algorithm only requires a single tree traversal (Goolsby, In Review). This function is several hundred to several thousand times faster than the rerooting method used in fastAnc, which is the next-fastest maximum likelihood ancestral state reconstruction method currently described (Revell 2012). As in the fastAnc function, the variance and 95% intervals of estimates are optionally returned.

Usage

anc.recon(trait_data, tree, vars = FALSE, CI = FALSE)

Arguments

trait_data
A vector or matrix of trait values. Names or row names correspond to species names. Data cannot have any missing data or within-species variation (this type of data can be handled by the phylopars function).
tree
An object of class phylo.
vars
Whether to return the variances of the restricted maximum likelihood estimates
CI
Whether to return 95% confidence intervals of the restricted maximum likelihood estimates

Value

A named vector of maximum likelihood ancestral states (with names corresponding to node names if available or node numbers from the tree rearranged in postorder, as obtained by the command reorder(tree,"postorder")). If vars or CI is set to TRUE, a list is returned with these values included.

See Also

fastAnc, ace, pic

Examples

Run this code
require(ape)
tree <- rtree(10000) # random tree with 10,000 taxa
x <- setNames(rnorm(1e4),tree$tip.label) # random trait data
recon <- anc.recon(trait_data=x,tree=tree)

Run the code above in your browser using DataLab