anc.Bayes | R Documentation |
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, ...)
tree |
an object of class |
x |
a vector of tip values for species; |
ngen |
a integer indicating the number of generations for the MCMC. |
control |
a list of control parameters containing the following elements: |
... |
optional arguments, including to be passed to |
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:
mcmc |
a data frame with rows |
tree |
our input phylogeny. |
Liam Revell liam.revell@umb.edu
Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). PeerJ, 12, e16505.
ace
, anc.ML
, anc.trend
, evol.rate.mcmc
, fastAnc
## set seed
set.seed(77)
## 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)))
## run MCMC (should be run at least 1e6 generations)
mcmc<-anc.Bayes(mammal.tree,ln.bodyMass,
ngen=50000)
print(mcmc,printlen=20) ## estimates
par(mfrow=c(2,1))
plot(mcmc,bty="l",main="Likelihood-profile from MCMC",
font.main=3) ## likelihood-profile
plot(density(mcmc,what=Ntip(mammal.tree)+1,
burnin=20000),bty="l",
main="Posterior density for root state of log(body mass)",
font.main=3)
par(mfrow=c(1,1)) ## reset par to default
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.