ancestral {cauphy} | R Documentation |
Posterior density of a node
Description
Compute the posterior density of a node value under a fitted Cauchy process on a phylogenetic tree.
Usage
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, ...)
Arguments
x |
|
... |
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. |
Details
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.
Value
an object of S3 class ancestralCauchy
,
which is a matrix of posterior values, with nodes in rows and values in columns.
Methods (by class)
References
Bastide, P. and Didier, G. 2023. The Cauchy Process on Phylogenies: a Tractable Model for Pulsed Evolution. Systematic Biology. doi:10.1093/sysbio/syad053.
See Also
fitCauchy
, cauphylm
,
plot.ancestralCauchy
, plot_asr
, increment
,
hdi.ancestralCauchy
Examples
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")