ancestral | R Documentation |
Compute the posterior density of a node value under a fitted Cauchy process on a phylogenetic tree.
ancestral(x, ...)
## S3 method for class 'cauphylm'
ancestral(x, node, values, n_values = 100, n_cores = 1, ...)
## S3 method for class 'cauphyfit'
ancestral(x, node, values, n_values = 100, n_cores = 1, ...)
x |
an object of class |
... |
other arguments to be passed to the method. |
node |
the vector of nodes for which to compute the posterior density. If not specified, the reconstruction is done on all the nodes. |
values |
the vector of values where the density should be computed.
If not specified, the reconstruction is done for a grid of |
n_values |
the number of point for the grid of values.
Default to |
n_cores |
number of cores for the parallelization. Default to 1. |
This function assumes a Cauchy Process on the tree with fitted parameters
(see fitCauchy
),
and computes the posterior ancestral density of internal nodes,
conditionally on the vector of tip values.
It computes the posterior density on all the points in values
,
that should be refined enough to get a good idea of the density curve.
an object of S3 class ancestralCauchy
,
which is a matrix of posterior values, with nodes in rows and values in columns.
ancestral(cauphylm)
: cauphylm
object
ancestral(cauphyfit)
: fitCauchy
object
Bastide, P. and Didier, G. 2023. The Cauchy Process on Phylogenies: a Tractable Model for Pulsed Evolution. Systematic Biology. doi:10.1093/sysbio/syad053.
fitCauchy
, cauphylm
,
plot.ancestralCauchy
, plot_asr
, increment
,
hdi.ancestralCauchy
set.seed(1289)
# Simulate tree and data
phy <- ape::rphylo(10, 0.1, 0)
dat <- rTraitCauchy(n = 1, phy = phy, model = "cauchy",
parameters = list(root.value = 10, disp = 0.1))
# Fit the data
fit <- fitCauchy(phy, dat, model = "cauchy", method = "reml")
# Reconstruct the ancestral nodes
anc <- ancestral(fit)
plot_asr(fit, anc = anc, offset = 3)
plot(anc, type = "l", node = c(11, 17))
# Refine grid for node 12 and 17
anc2 <- ancestral(fit, node = c(12, 17), n_values = 1000)
plot(anc2, type = "l")
# Find HDI
library(HDInterval)
hdi_anc <- hdi(anc2)
hdi_anc
plot(anc2, interval = hdi_anc, type = "l")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.