View source: R/getEnvironCov.gllvm.R
getEnvironCov.gllvm | R Documentation |
Calculates the species environment covariance matrix for a gllvm object.
## S3 method for class 'gllvm'
getEnvironCov(object, x = NULL, ...)
object |
an object of class 'gllvm'. |
x |
(optional) vector of covariate values to calculate the covariance for. Defaults to a vector of 1s. |
... |
not used |
Species covariance matrix due to the environment is calculated.
Covariances due to the covariates can only be calculated when random effects are included in the model, and are thus limited to reduced rank models (those including constrained and concurrent ordinations) fitted with random slopes, models fitted with random effects via the formula interface, or the fourth corner model fitted with random slopes. For full rank models with random slopes, i.e., with the formula interface or the fourth corner model, the covariances of species are formulated as:
\Sigma_e = C*kronecker(P\rho + (1-\rho)I_p, R)*C',
where P is a correlation matrix for the columns in the response (e.g., a Phylogenetic matrix), \rho_{sp}
the signal parameter, and R the covariance matrix for the random effects. Here,
C = kronecker(I_p, 1_r)
, with 1_r a vector of 1s equal to the number of random effects.
For reduced rank models, the covariance is separately defined for the different variance structures of the canonical coefficients in the package. With LV-specific variances, we have:
\Sigma_e = \Theta*S*\Theta',
where \Theta
is the matrix of loadings, and S the (diagonal) covariance matrix for the canonical coefficients. With predictor-specific variances, we instead have:
\Sigma_e = \sum^K_{k=1} \Theta(I_d*\sigma_k^2)\Theta',
with I_d an identity matrix for the number of constrained and informed latent variables, and \sigma_k^2
the variance per predictor for the canonical coefficients.
Function returns the following components:
cov |
species covariances due to covariates |
trace.randomB |
trace of the covariance matrix due to random canonical coefficients |
trace.randomB.quad |
trace of the covariance matrix components due to squared model terms |
trace.col.eff |
trace of the covariance matrix due to random column (species) effects |
Bert van der Veen
getEnvironCor
,getResidualCov.gllvm
, getResidualCor.gllvm
,.
## Not run:
# Example with the spider dataset
data(spider)
fit <- gllvm(spider$abund, X = scale(spider$x), num.RR = 2, randomB = "P", family = "negative.binomial")
envcov <- getEnvironCov(fit)
envcov$trace.randomB
# As proportion of variance in the model
envcov$trace.randomB/sum(envcov$trace.randomB)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.