The function fitMk
fits a so-called Mk model for discrete character evolution.
plot.fitMk
plots an object of class "fitMk"
returned by fitMk
. plot.gfit
plots an object of class "gfit"
from geiger's fitDiscrete
function. Both plots portray the fitted model using a graph of arrows connecting states.
The function fitmultiMk
fits an Mk model in which the transition rates between character states are allowed to vary depending on the mapped state of a discrete character on the tree. It can be combined with, for example, paintSubTree
to test hypotheses about how the process of discrete character evolution for x
varies between different parts of the tree.
The function fitpolyMk
fits an Mk model to data for a discrete character with intraspecific polymorphism. Polymorphic species should be coded with the name of the two or more states recorded for the species separated by a space (e.g., A+B
would indicate that both states A
and B
are found in the corresponding taxon). Invariably it's assumed that transitions between states must occur through a polymorphic condition, whereas transitions cannot occur directly between two incompatible polymorphic conditions. For instance, a transition between A+B
and B+C
would have to occur through the monomorphic state B
. At time of writing, this function permits the models "ER"
(equal rates for all permitted transitions), "SYM"
(symmetric backward & forward rates for all permitted transitions), "ARD"
(all-rates-different for permitted transitions), and a new model called "transient"
in which the acquisition of polymorphism (e.g., A -> A+B
) is assumed to occur at a different rate than its loss (e.g., A+B -> B
). The method plot.fitpolyMk
plots the fitted Mk model with intraspecific polymorphism.
Finally, the function mcmcMk
runs a Bayesian MCMC version of fitMk
. The shape of the prior distribution of the transition rates is exponential, with a rate parameter that can be controlled by the user via the optional argument prior.rate
. The shape of the proposal distribution is normal, with mean zero and a variance that can be controlled by the user via the optional argument prior.var
. The method plot.mcmcMk
plots a log-likelihood trace from the MCMC. The method density.mcmcMk
computes a posterior density on the transition rates in the model from the posterior sample obtained in the MCMC, will import the package coda if it is available, and returns an object of class "density.mcmcMk"
. Finally, the method plot.density.mcmcMk
creates a plot of the posterior density (or a set of plots) for the transition rates between states.
fitMk(tree, x, model="SYM", fixedQ=NULL, ...)
# S3 method for fitMk
plot(x, ...)
# S3 method for gfit
plot(x, ...)
fitmultiMk(tree, x, model="ER", ...)
fitpolyMk(tree, x, model="SYM", ordered=FALSE, ...)
# S3 method for fitpolyMk
plot(x, ...)
mcmcMk(tree, x, model="ER", ngen=10000, ...)
# S3 method for mcmcMk
plot(x, ...)
# S3 method for mcmcMk
density(x, ...)
# S3 method for density.mcmcMk
plot(x, ...)
# S3 method for gfit
logLik(object, ...)
an object of class "phylo"
. In the case of fitmultiMk
an object of class "simmap"
with a mapped discrete character.
a vector of tip values for species; names(x)
should be the species names. In the case of plot
and density
methods, an object of the appropriate class.
model. See make.simmap
or ace
for details.
fixed value of transition matrix Q
, if one is desired.
for fitpolyMk
, a logical value indicating whether or not the character should be treated as ordered. For now the function assumes alphanumerical order (i.e., numbers sorted by their initial and then successive digits followed by characters or character strings in alphabetical order).
number of generations of MCMC for mcmcMk
.
optional arguments, including pi
, the prior distribution at the root node (defaults to pi="equal"
). For plot
method optional arguments include (but may not be limited to): signif
, the number of digits for the rates to be plotted; main
, a character vector of length two with the headings for each subplot; cex.main
, cex.traits
, and cex.rates
, font sizes for the various text elements of the plot; and show.zeros
, a logical argument specifying whether or not to plot arrows with the ML estimated transition rate is not different from zero (with tolerance specified by the optional argument tol
).
for logLik.gfit
, object of class "gfit"
.
An object of class "fitMk"
, "fitmultiMk"
, "fitpolyMk"
, or "mcmcMk"
. In the case of density.mcmcMk
an object of class "density.mcmcMk"
.
Note that both fitMk
and fitmultiMk
recycle code from ace
in the ape package for computing the likelihood. fitpolyMk
and mcmcMk
use fitMk
internally to compute the likelihood.
Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol., 3, 217-223.