anc.Bayes: Bayesian ancestral character estimation

View source: R/anc.Bayes.R

anc.BayesR Documentation

Bayesian ancestral character estimation


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


anc.Bayes(tree, x, ngen=10000, control=list(), ...)
## S3 method for class 'anc.Bayes'
plot(x, ...)
## S3 method for class 'anc.Bayes'
density(x, ...)



an object of class "phylo".


a vector of tip values for species; names(x) should be the species names. In the case of the plot and density methods, an object of class "anc.Bayes".


a integer indicating the number of generations for the MCMC.


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.


optional arguments, including to be passed to plot and density methods.


plot.anc.Bayes generates a likelihood profile plot of the MCMC by default, but can also create a profile plot for any of the sampled variables by using the optional argument what. For instance, what=40 (or, equivalently, what="40") will create a profile plot of the MCMC for node 40. Additional arguments are passed to plot.

density.anc.Bayes computes a posterior density from the MCMC sample. Like plot.anc.Bayes takes the optional argument what, but unlike plot.anc.Bayes computes the posterior density for the root node by default. The object computed by this function is of class "density" and can be visualized using plot.density. Burn-in (in generations) can be set using the optional argument burnin, otherwise it will be assumed to be 20

The print and summary methods for this object class also return (invisibly) a vector of estimated ancestral states based on a user-supplied burn-in (or 20% of the number of generations of MCMC, if no burn-in is provided). Burn-in can be specified with the optional argument burnin.


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


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.


our input phylogeny.


Liam Revell


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


## set seed
## load data from Garland et al. (1992)
## extract character of interest
## run MCMC (should be run at least 1e6 generations)
print(mcmc,printlen=20) ## estimates
plot(mcmc,bty="l",main="Likelihood-profile from MCMC",
    font.main=3) ## likelihood-profile
    main="Posterior density for root state of log(body mass)",
par(mfrow=c(1,1)) ## reset par to default

phytools documentation built on Nov. 10, 2023, 1:08 a.m.