Learn R Programming

boral (version 0.5)

get.enviro.cor: Extract correlations due to shared environmental responses from boral models

Description

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

Usage

get.enviro.cor(y, X, fit.mcmc, est = "median")

Arguments

y
The response matrix that the boral model was fitted to.
X
The model matrix that was used in the boral model.
fit.mcmc
All MCMC samples for the fitted boral model, as obtained from JAGS. These can be extracted by fitting an boral model using boral with save.model = TRUE, and then applying as.mcmc on
est
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.

Value

  • A $p \times p$ correlation matrix matrix based on model matrix and the posterior or mean estimators of the associated regression coefficients.

Details

In both independent column and correlated column models, where the each of the columns of the response matrix y are fitted to a set of explanatory variables given by X, the correlation 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}'_i\bm{\beta}_j$ and $\bm{x}'_i\bm{\beta}_{j'})$, where $\bm{\beta}_j$ are column-specific coefficients relating to the explanatory variables (see also the help file for boral).

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.

References

  • Ovaskainen et al. (2010). Modeling species co-occurrence by multivariate logistic regression generates new hypotheses on fungal interactions. Ecology, 91, 2514-2521.
  • Pollock et al. (2014). Understanding co-occurrence by modelling species simultaneously with a Joint Species Distribution Model (JSDM). Methods in Ecology and Evolution, 5, 397-406.

See Also

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

Examples

Run this code
library(mvabund) ## Load a dataset from the mvabund package
library(corrplot) ## For plotting correlations
data(spider)
y <- spider$abun
n <- nrow(y); p <- ncol(y); 
    
spider.fit.nb <- boral(y, X = spider$x, family = "negative.binomial", num.lv = 2, 
     row.eff = FALSE, n.burnin = 10, n.iteration = 100, 
     n.thin = 1, save.model = TRUE, calc.ics = FALSE)

enviro.cors <- get.enviro.cor(y, X = spider$x, 
	fit.mcmc = as.mcmc(spider.fit.nb$jags.model)[[1]])

corrplot(enviro.cors, title = "Shared response correlations", type = "lower")

Run the code above in your browser using DataLab