glinv_gauss {glinvci} | R Documentation |
Construct an object representing a GLInv model with respect to the underlying Gaussian process parameters.
Description
The glinv_gauss
function constructs an object of class glinv_gauss
, which represents a lower-level
GLInv model with respect to the underlying Gaussian process space. The likelihood Hessian of, for example, Brownian motion
and Ornstein-Uhlenbeck models can be computed by applying the calculus chain rule to the output of Jacobians and Hessians
from this class.
The lik.glinv_gauss
function computes the likelihood of a full glinv_gauss
model.
The grad.glinv_gauss
function computes the log-likelihood gradients of a glinv_gauss
models.
If par
is NULL, it returns a function that, when called, returns the same thing as if grad.glinv_gauss
were called with par
argument.
The hess.glinv_gauss
function computes the log-likelihood Hessian of a glinv_gauss
models.
Usage
glinv_gauss(tree, x0, dimtab = NULL, X = NULL)
## S3 method for class 'glinv_gauss'
lik(mod, par = NULL, ...)
## S3 method for class 'glinv_gauss'
grad(mod, par = NULL, lik = FALSE, num_threads = 2L, ...)
## S3 method for class 'glinv_gauss'
hess(
mod,
par = NULL,
lik = FALSE,
grad = FALSE,
directions = NULL,
num_threads = 2L,
...
)
## S3 method for class 'glinv_gauss'
print(x, ...)
Arguments
tree |
A tree of class |
x0 |
A vector representing the root's trait vector. |
dimtab |
An integer, a vector of integers, or NULL, specifying the number of dimensions of each nodes of the tree.
If it is a vector, |
X |
Trait values, either a matrix in which |
mod |
A model object of class |
par |
A vector, containing the parameters at which the likelihood should be computed. |
... |
Not used. |
lik |
If |
num_threads |
Number of threads to use. |
grad |
If |
directions |
Either |
x |
An object of class |
Details
The glinv_gauss
class does not include any information for dealing with evolutionary regimes, lost traits, and
missing data, nor does it facilitate reparametrisation. These are all functionality of the glinv
class instead.
The member variables of the objects of the glinv_gauss
class only are for the users' convenience to read
the information about the model, and the user should not modify its member variables directly.
For each non-root node in the phylogeny, the multivariate trait vector
follows
a Gaussian distribution with mean
and variance
when conditioned on
the mother's trait vector
. The ‘parameters’ of this model is, therefore, the joint of all
for all nodes
. The root does not have any associated parameters.
The parameter vector par
should be the concatenation of all in accending
order sorted by
, the node number (which is the same node numbers as in
tree$edge
). The matrix
is flattened in column-major order and
is the lower-triangular part of V_i,
column-major-flattened. Since the root does not have parameters, its entry is simply skipped.
For example, if a binary tree has 10 non-root nodes in total and each of them are 3 dimensional, then
each
should have
elements; thus after concatenation
par
should
be a 180 elements.
Value
An object of S3 class glinv_gauss
with the following components
- ctree
A pointer to an internal C structure.
- apetree
Same as the
tree
argument but with some pre-processing in its edge table- origtree
The
tree
argument.- x0
The trait vector at the root of the tree.
- dimtab
Identical to the
dimtab
argument.- gaussdim
The number of dimension of the parameter space of this model.
References
Mitov V, Bartoszek K, Asimomitis G, Stadler T (2019). “Fast likelihood calculation for multivariate Gaussian phylogenetic models with shifts.” Theor. Popul. Biol.. https://doi.org/10.1016/j.tpb.2019.11.005.
Examples
tr = ape::rtree(3)
model = glinv_gauss(tr, x0=c(0,0), X=matrix(rnorm(6),2,3))
par = unlist(
list(
list('Phi' = c(1,0,0,1), # Parameters for node #1, a tip
'w' = c(-1,1),
'V' = c(1,0,1)), # Lower triangular part of a 2D identity matrix
list('Phi' = c(2,0,0,2), # For node #2, a tip
'w' = c(-2,2),
'V' = c(2,0,2)),
list('Phi' = c(3,0,0,3), # For node #3, a tip
'w' = c(-3,3),
'V' = c(3,0,3)),
list('Phi' = c(4,0,0,4), # For node #5. Node #4 skipped as it is the root
'w' = c(-4,4),
'V' = c(4,0,4))
))
print(par)
lik(model, par)
grad(model, par)
hess(model, par)