threshBayes: Threshold model using Bayesian MCMC

View source: R/threshBayes.R

threshBayesR Documentation

Threshold model using Bayesian MCMC

Description

Fits the threshold model from quantitative genetics to data for two discrete characters or one discrete and one continuous trait, following Felsenstein (2012).

Usage

threshBayes(tree, X, types=NULL, ngen=10000, control=list(), ...)

Arguments

tree

an object of class "phylo".

X

a matrix or data frame containing values for a discrete character and a continuous character; or two discrete characters. The row names of X should be species names.

types

a vector of length ncol(X) containing the data types for each column of X, for instance c("discrete","continuous").

ngen

a integer indicating the number of generations for the MCMC.

control

a list of control parameters for the MCMC. Control parameters include: sample, the sampling interval for the MCMC; propvar, a vector containing (in this order) proposal variances for the two rates (if the type is "discrete" this will be ignored), the two ancestral states, and the correlation; propliab, a single proposal variance for the liabilities; pr.mean, a vector for the mean of the prior probability distributions for each parameter, in the same order as propvar; pr.liab, currently ignored; pr.var, a vector with variances for the prior densities for each parameter, in the same order as pr.mean - note that for the rates we use an exponential distribution so the first two means are currently ignored; and pr.vliab currently ignored.

...

other optional arguments. The argument auto.tune adjusts the proposal distribution to target an proposal acceptance rate (of 0.234, by default).

Details

This function uses Bayesian MCMC to fit the quantitative genetics threshold model (Felsenstein 2012) to data for two discrete characters or one discrete and one continuous character.

The plot method for the object class can be used to generate a three panel plot showing the likelihood profile, the mean acceptance rates (using a sliding window), and a profile plot for the correlation coefficient, r.

The density method for the object can be used to plot a posterior density of the correlation coefficient, r. This posterior density is of class "density.threshBayes" which can also be plotted using an plot method.

Discrete characters must be binary, but can be coded as any factor.

Value

This function returns an object of class "threshBayes" consisting of a list with at least the following two elements: par a matrix containing the posterior sample for the model parameters (evolutionary rates, ancestral states, and correlation); liab a matrix containing the posterior sample of the liabilities. For continuous characters, the liabilities are treated as known and so the posterior samples are just the observed values.

Author(s)

Liam Revell liam.revell@umb.edu

References

Felsenstein, J. (2012) A comparative method for both discrete and continuous characters using the threshold model. American Naturalist, 179, 145-156.

Revell, L. J. (2014) Ancestral character estimation under the threshold model from quantitative genetics. Evolution, 68, 743-759.

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

See Also

anc.Bayes, bmPlot, evol.rate.mcmc

Examples

## Not run: 
## load data
data(bonyfish.tree)
data(bonyfish.data)
## run MCMC
mcmc<-threshBayes(bonyfish.tree,bonyfish.data,
    ngen=100000,plot=FALSE)
## visualize summary of MCMC
plot(mcmc)
## reset par
par(mfrow=c(1,1),mar=c(5.1,4.1,4.1,2.1))
## graph posterior density of correlation
plot(density(mcmc,bw=0.1))
## End(Not run)

phytools documentation built on June 22, 2024, 10:39 a.m.