Learn R Programming

phytools (version 0.7-20)

anc.Bayes: Bayesian ancestral character estimation

Description

This function uses Bayesian MCMC to sample from the posterior distribution for the states at internal nodes in the tree.

Usage

anc.Bayes(tree, x, ngen=10000, control=list())

Arguments

tree

an object of class "phylo".

x

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

ngen

a integer indicating the number of generations for the MCMC.

control

a list of control parameters containing the following elements: sig2: starting value for \(\sigma^2\) (BM rate); a: starting for the state at the root node; y: starting values for the states at all internal nodes excluding the root (should be labeled with node numbers); pr.mean: means for the prior distributions in the following order - sig2, a, y, note that the prior probability distribution is exponential for sig2 and normal for a and y; pr.var: variances on the prior distributions, same order as pr.mean (but the variance is not used for sig2); prop: variances on the normal proposal distributions in the same order as pr.mean; sample: sample frequency from the MCMC.

Value

An object of class "anc.Bayes" including at least two components:

mcmc

a data frame with rows ngen/sample+1 containing the posterior sample and likelihoods. Matrix columns are labeled either sig2 or by the node number of the internal node.

tree

our input phylogeny.

Details

The print method also returns (invisibly) a vector of estimated ancestral states based on a user-supplied burn-in (or 20

The object class plot method by default plots a likelihood profile from the MCMC.

References

Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol., 3, 217-223.

See Also

ace, anc.ML, anc.trend, evol.rate.mcmc, fastAnc

Examples

Run this code
# NOT RUN {
tree<-pbtree(n=50)
x<-fastBM(tree,sig2=2) # simulate using fastBM
obj<-anc.Bayes(tree,x,ngen=10000) # sample ancestral states
print(obj,printlen=20) ## estimates
# }

Run the code above in your browser using DataLab