get.enviro.cor {boral}R Documentation

Extract covariances and correlations due to shared environmental responses



Calculates the correlation between columns of the response matrix, due to similarities in the response to explanatory variables i.e., shared environmental response.


get.enviro.cor(object, est = "median", prob = 0.95)



An object for class "boral".


A choice of either the posterior median (est = "median") or posterior mean (est = "mean"), which are then treated as estimates and the fitted values are calculated from. Default is posterior median.


A numeric scalar in the interval (0,1) giving the target probability coverage of the intervals, by which to determine whether the correlations are "significant". Defaults to 0.95.


In both independent response and correlated response models, where the each of the columns of the response matrix \bm{Y} are fitted to a set of covariates, the covariance and thus between two columns j and j' due to similarities in their response to the model matrix is calculated based on the linear predictors \bm{x}^\top_i\bm{\beta}_j and \bm{x}^\top_i\bm{\beta}_{j'}), where \bm{\beta}_j are response-specific coefficients relating to the explanatory variables.

For multivariate abundance data, the correlation calculated by this function can be interpreted as the correlation attributable to similarities in the environmental response between species. Such correlation matrices are discussed and found in Ovaskainen et al., (2010), Pollock et al., 2014.

Please note this correlation calculation does not include any row effects or any response-specific random intercepts.


A list with the following components:

cor, cor.lower, cor.upper

A set of p \times p correlation matrices, containing either the posterior median or mean estimate plus lower and upper limits of the corresponding (100\timesprob) % HPD interval.


A p \times p correlation matrix containing only the “significant" correlations whose (100\timesprob) % HPD interval does not contain zero. All non-significant correlations are set to zero.


A p \times p covariance matrix.


Francis K.C. Hui [aut, cre], Wade Blanchard [aut]

Maintainer: Francis K.C. Hui <>


See Also

get.residual.cor, which calculates the residual correlation matrix for models involving latent variables.


## Not run: 
## NOTE: The values below MUST NOT be used in a real application;
## they are only used here to make the examples run quick!!!
example_mcmc_control <- list(n.burnin = 10, n.iteration = 100, 
     n.thin = 1)
testpath <- file.path(tempdir(), "jagsboralmodel.txt")

library(mvabund) ## Load a dataset from the mvabund package
library(corrplot) ## For plotting correlations
y <- spider$abun
X <- scale(spider$x)
n <- nrow(y)
p <- ncol(y)
spiderfit_nb <- boral(y, X = X, family = "negative.binomial", 
     save.model = TRUE, mcmc.control = example_mcmc_control, = testpath)

enviro.cors <- get.enviro.cor(spiderfit_nb)

corrplot(enviro.cors$sig.cor, title = "Shared response correlations", 
	type = "lower", diag = FALSE, mar = c(3,0.5,2,1), = 45)

## End(Not run)

[Package boral version 2.0.2 Index]