Learn R Programming

phytools (version 2.3-0)

fastAnc: (Reasonably) fast estimation of ML ancestral states

Description

Estimates ancestral states for a continuous character under maximum likelihood.

Usage

fastAnc(tree, x, vars=FALSE, CI=FALSE, ...)

Value

An object of class "fastAnc" consisting of either: a named vector containing the states at internal nodes - names are node numbers; or a list containing ancestral state estimates (ace), variances on the estimates (var), and/or 95% confidence intervals (CI95).

Arguments

tree

an object of class "phylo".

x

a vector of tip values for species; names(x) should be the species names.

vars

a logical value indicating whether or not to compute variances on the ancestral state estimates. Variances are based on Equation (6) of Rohlf (2001).

CI

a logical value indicating whether or not to compute 95% confidence intervals on state estimates.

...

optional arguments. Presently this consists of anc.states, a named vector containing ancestral states to fix. Names should correspond to node numbers in the input tree.

Author

Liam Revell liam.revell@umb.edu

Details

This function performs (reasonably) fast estimation of the ML ancestral states for a continuous trait by taking advantage of the fact that the state computed for the root node of the tree during Felsenstein's (1985) contrasts algorithm is also the MLE of the root node. Thus, the function re-roots the tree at all internal nodes and computes the contrasts state at the root each time.

The function can also (optionally) compute variances or 95% confidence intervals on the estimates.

References

Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). PeerJ, 12, e16505.

See Also

ace, anc.Bayes, anc.ML, pic

Examples

Run this code
## load data from Garland et al. (1992)
data(mammal.tree)
data(mammal.data)
## extract character of interest
ln.bodyMass<-log(setNames(mammal.data$bodyMass,
    rownames(mammal.data)))
## estimate ancestral body sizes
fit.BM<-fastAnc(mammal.tree,ln.bodyMass,CI=TRUE)
print(fit.BM,printlen=10)

Run the code above in your browser using DataLab