getResidualCov.gllvm {gllvm} | R Documentation |
Extract residual covariance matrix from gllvm object
Description
Calculates the residual covariance matrix for gllvm model.
Usage
## S3 method for class 'gllvm'
getResidualCov(object, adjust = 1, site.index = NULL, ...)
Arguments
object |
an object of class 'gllvm'. |
adjust |
The type of adjustment used for negative binomial, binomial and normal distribution when computing residual correlation matrix. Options are 0 (no adjustment), 1 (the default adjustment) and 2 (alternative adjustment for NB distribution), see details. |
site.index |
A site index, vector of length one or 1, that is used in the calculation of a GLLVM with quadratic response model. |
... |
not used. |
Details
Residual covariance matrix, storing information on species co-occurrence that is not explained by the environmental variables (if included), is calculated using the matrix of latent variables loadings, that is, , and the dispersion parameter related to the distribution of choice, is applicable (e.g. in the case of negative-binomial distributed responses).
When the responses are modelled using the negative binomial distribution, the residual variances for each species must be adjusted for overdispersion. The two possible adjustment terms are (
adjust = 1
) and (
adjust = 2
), where is the trigamma function.
The negative binomial model can be written using different parameterizations.
The residual covariance with adjust = 1
can be obtained using the lognormal-Poisson parametrization, that is,
where and
and
. Now
and variance
, which are the same as for the NB distribution.
Therefore, on linear predictor scale, we have the variance
which leads to the residual covariance matrix , where
is the diagonal matrix with
as diagonal elements (
adjust = 1
).
Or, for a GLLVM where species are a quadratic function of the latent variables, we instead have
which leads to the residual covariance matrix , where
holds the quadratic coefficients.
Since the quadratic coefficients are constrained to be positive, the residual covariance in the latter case is, given the same coefficients on the linear term, equal or more positive than in the linear case.
The residual covariance matrix with adjust = 2
can be obtained by using Poisson-Gamma parametri-zation
where and
is as above. The mean and the variance are of similar form as above and we have that
where is the trigamma function.
In the case of binomial distribution, the adjustment terms (adjust = 1
) are 1 for probit link and for logit link.
These are obtained by treating binomial model as latent variable model. Assume
where for probit model, and
for logit model.
Then binary response is defined as
, if
and 0 otherwise.
Now we have that
which leads to probit and logit models.
On linear predictor scale we then have that
For the probit model, the residual covariance matrix is then , and for the logit model
.
Similarly as above, for a GLLVM where species are a quadratic function of the latent variables, the term
is added to the residual covariance matrix.
For normal distribution, we can write
where and thus we have that
For the gaussian model, the residual covariance matrix is then .
Value
Function returns following components:
cov |
residual covariance matrix |
trace |
trace of the residual covariance matrix, the total variance explained |
var.q |
trace of the residual covariance matrix per latent variable, variance explained per latent variable |
var.q2 |
trace of the squared term of the residual covariance matrix per latent variable, for quadratic responses. Variance explained per latent variable by the quadratic term |
Author(s)
Francis K.C. Hui, Jenni Niku, David I. Warton, Bert van der Veen
Examples
## Not run:
# Load a dataset from the mvabund package
data(antTraits)
y <- as.matrix(antTraits$abund)
# Fit gllvm model
fit <- gllvm(y = y, family = poisson())
# residual covariance:
rescov <- getResidualCov(fit)
rescov$cov
# Trace of the covariance matrix
rescov$trace
# Variance explained per latent variable
rescov$var.q
## End(Not run)