codep (version 1.2-3)

codep-package: tools:::Rd_package_title("codep")

Description

tools:::Rd_package_description("codep") Multiscale Codependence Analysis (MCA) consists in assessing the coherence of pairs of variables in space (or time) using the product of their correlation coefficients with series of spatial (or temporal) eigenfunctions. That product, which is positive or negative when variables display similar or opposing trends, respectively, is called a codependence coefficient.

The eigenfunctions used in the calculation are obtained in three steps: 1) a distance matrix is calculated from the locations of samples in space (or the sampling organisation through time). 2) From that distance matrix, a matrix of Moran spatial weights is obtained; this is the same matrix as used to calculate Moran's autocorrelation index, hence the name. And 3) the spatial weight matrix is eigenvalue-decomposed after centring the rows and columns of the spatial weight matrix.

The statistical significance of codependence coefficients is tested using parametric or permutational testing of a tau statistic. The `tau` statistic is the product of the Student's `t` statistics obtained from comparison of the two variables with a given eigenfunction. The `tau` statistic can take either positive or negative values, thereby allowing one to perform one-tailed or two-tailed testing. For multiple response variables, testing is performed using the `phi` statistic instead of `tau`. That statistic follows the distribution of the product of two Fisher-Snedocor F statistics (see product-distribution for details).

Arguments

Author

tools:::Rd_package_author("codep") Maintainer: tools:::Rd_package_maintainer("codep")

Details

Function MCA performs Multiscale Codependence Analysis (MCA). Functions test.cdp and permute.cdp handle parametric or permutation testing of the codependence coefficients, respectively.

Methods are provided to print and plot cdp-class objects (print.cdp and plot.cdp, respectively) as well as summary (summary.cdp), fitted values (fitted.cdp), residuals (residuals.cdp), and for making predictions (predict.cdp).

Function eigenmap calculates spatial eigenvector maps following the approach outlined in Dray et al. (2006), and which are necessary to calculate MCA. It returns a eigenmap-class object. The package also features methods to print (print.eigenmap) and plot (plot.eigenmap) these objects. Function eigenmap.score can be used to make predictions for spatial models built from the eigenfunctions of eigenmap using distances between one or more target locations and the sampled locations for which the spatial eigenvector map was built.

The package also features an exemplary dataset salmon containing 76 sampling site positions along a 1520 m river segment. It also contains functions cthreshold and minpermute, which compute the testwise type I error rate threshold corresponding to a given familywise threshold and the minimal number of permutations needed for testing Multiscale Codependence Analysis given the alpha threshold, respectively.

The DESCRIPTION file: tools:::Rd_package_DESCRIPTION("codep") tools:::Rd_package_indices("codep")

References

Dray, S.; Legendre, P. and Peres-Neto, P. 2006. Spatial modelling: a comprehensive framework for principal coordinate analysis of neighbor matrices (PCNM). Ecol. Modelling 196: 483-493

Guénard, G., Legendre, P., Boisclair, D., and Bilodeau, M. 2010. Multiscale codependence analysis: an integrated approach to analyse relationships across scales. Ecology 91: 2952-2964

Guénard, G. Legendre, P. 2018. Bringing multivariate support to multiscale codependence analysis: Assessing the drivers of community structure across spatial scales. Meth. Ecol. Evol. 9: 292-304

See Also

Legendre, P. and Legendre, L. 2012. Numerical Ecology, 3rd English edition. Elsevier Science B.V., Amsterdam, The Neatherlands.

Examples

Run this code
data(mite)
emap <- eigenmap(x = mite.geo, weighting = wf.RBF, wpar = 0.1)
emap

## Organize the environmental variables
mca0 <- MCA(Y = log1p(mite.species), X = mite.env, emobj = emap)
mca0_partest <- test.cdp(mca0, response.tests = FALSE)
summary(mca0_partest)
plot(mca0_partest, las = 2, lwd = 2)
plot(mca0_partest, col = rainbow(1200)[1L:1000], las = 3, lwd = 4,
     main = "Codependence diagram", col.signif = "white")

rng <- list(x = seq(min(mite.geo[,"x"]) - 0.1, max(mite.geo[,"x"]) + 0.1, 0.05),
            y = seq(min(mite.geo[,"y"]) - 0.1, max(mite.geo[,"y"]) + 0.1, 0.05))
grid <- cbind(x = rep(rng[["x"]], length(rng[["y"]])),
              y = rep(rng[["y"]], each = length(rng[["x"]])))
newdists <- matrix(NA, nrow(grid), nrow(mite.geo))
for(i in 1L:nrow(grid)) {
  newdists[i,] <- ((mite.geo[,"x"] - grid[i,"x"])^2 +
                   (mite.geo[,"y"] - grid[i,"y"])^2)^0.5
}

spmeans <- colMeans(mite.species)
pca0 <- svd(log1p(mite.species) - rep(spmeans, each = nrow(mite.species)))

prd0 <- predict(
  mca0_partest,
  newdata = list(target = eigenmap.score(emap, newdists))
)
Uprd0 <- (prd0 - rep(spmeans, each = nrow(prd0))) %*% pca0$v %*%
  diag(pca0$d^-1)

## Printing the response variable
prmat <- Uprd0[,1L]
dim(prmat) <- c(length(rng$x), length(rng$y))
zlim <- c(min(min(prmat), min(pca0$u[,1L])), max(max(prmat), max(pca0$u[,1L])))
image(z = prmat, x = rng$x, y = rng$y, asp = 1, zlim = zlim,
      col = rainbow(1200L)[1L:1000], ylab = "y", xlab = "x")
points(
  x = mite.geo[,"x"], y = mite.geo[,"y"], pch = 21,
  bg = rainbow(1200L)[round(1+(999*(pca0$u[,1L] - zlim[1L])/
                    (zlim[2L] - zlim[1L])),0)]
)

Run the code above in your browser using DataLab