R/getResidualCor.gllvm.R
getResidualCor.gllvm.Rd
Calculates the residual correlation matrix for gllvm model.
# S3 method for class 'gllvm'
getResidualCor(object, adjust = 1, site.index = NULL, ...)
an object of class 'gllvm'.
The type of adjustment used for negative binomial and binomial distribution when computing residual correlation matrix. Options are 0 (no adjustment), 1 (the default adjustment) and 2 (alternative adjustment for NB distribution). See details.
A site index used used in the calculation of a GLLVM with quadratic response model, for which the residual correlations are calculated.
not used
Residual correlation matrix is calculated based on the residual covariance matrix, see details from getResidualCov.gllvm
.
#'# Extract subset of the microbial data to be used as an example
data(microbialdata)
y <- microbialdata$Y[, order(colMeans(microbialdata$Y > 0),
decreasing = TRUE)[21:40]]
fit <- gllvm(y, family = poisson())
fit$logL
#> [1] -4242.668
cr <- getResidualCor(fit)
cr[1:5,1:5]
#> OTU_79 OTU_164 OTU_462 OTU_95 OTU_833
#> OTU_79 1.0000000 0.3887252 0.3422382 -0.7491377 0.9955697
#> OTU_164 0.3887252 1.0000000 0.9987528 -0.9015266 0.4736348
#> OTU_462 0.3422382 0.9987528 1.0000000 -0.8787967 0.4290705
#> OTU_95 -0.7491377 -0.9015266 -0.8787967 1.0000000 -0.8081033
#> OTU_833 0.9955697 0.4736348 0.4290705 -0.8081033 1.0000000
if (FALSE) { # \dontrun{
# Load a dataset from the mvabund package
data(antTraits, package = "mvabund")
y <- as.matrix(antTraits$abund)
# Fit gllvm model
fit <- gllvm(y = y, family = poisson())
# residual correlations:
cr <- getResidualCor(fit)
# Plot residual correlations:
install.packages("corrplot", "gclus")
library(corrplot)
library(gclus)
corrplot(cr[order.single(cr), order.single(cr)], diag = F,
type = "lower", method = "square", tl.cex = 0.8, tl.srt = 45, tl.col = "red")
} # }