Learn R Programming

codep (version 0.2-1)

MCA: Multiscale Codependence Analysis

Description

Functions to perform Multiscale Codependence Analysis (MCA)

Usage

MCA(y, x, emobj)
test.mca(mcaobj, alpha = 0.05, max.step = Inf)
permute.mca(mcaobj, permute = NA, alpha = 0.05, max.step = Inf)

Arguments

y
A numeric vector containing the response variable.
x
A numeric vector containing the explanatory variable for functions test.mca or permute.mca.
emobj
A eigenmap-class object.
mcaobj
A mca-class object.
alpha
The type I ($\alpha$) error threshold used by the testing procedure.
max.step
The maximum number of steps to perform when testing for statistical significance.
permute
The number of random permutations used for testing. Obtained through minpermute when let to NA.

Value

encoding

utf8

Details

Multiscale Codependence Analysis (MCA) allows to calculate correlation-like (i.e.codependence) coefficients between two variables with respect to structuring variables (Moran's eigenvector maps). The analysis is performed using function mca. The purpose of this function is limited to parameter fitting. Test procedures are handled through test.mca (parametric testing) or permute.mca (permutation testing). Additionaly, methods are provided for printing, obtaining testing summary, plotting results, calculating fitted and residuals values, and making predictions. It is noteworthy that the test procedure used by MCA deviates from the standard R workflow since intermediate testing functions (test.mca and permute.mca) need first to be called before any testing be performed. For MCA testing functionalities had been moved away from summary.mca because of permutation testing, which is the most relevant option in practice, takes long time to run.

References

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

See Also

eigenmap

Examples

Run this code
#
### Example 1: Atlantic salmon in the St-Marguerite river, Quebec, Canada.
#
data(Salmon)
map <- eigenmap(x=Salmon[,"Position"],truncate=c(0,20),wf="binary")
mca1 <- MCA(y=log(Salmon[,"Abundance"]+1),x=Salmon[,"Substrate"],emobj=map)
mca1
plot(mca1)
summary(mca1)   # Works only with tested mca.
#
## Parametric test.
mcatest1 <- test.mca(mca1)
mcatest1
summary(mcatest1)
plot(mcatest1)
plot(Abundance~Position,data=Salmon, type="l")
lines(y=exp(fitted(mcatest1)-1),x=Salmon[,"Position"])
plot(x=Salmon[,"Abundance"],y=exp(fitted(mcatest1)-1),asp=1,xlim=c(0,14),ylim=c(0,14))
abline(0,1)
residuals(mcatest1)
#
## Permutation test. Warning: takes time to calculate.
mcapermute1 <- permute.mca(mca1)
mcapermute1
summary(mcapermute1)
plot(Abundance~Position,data=Salmon, type="l")
lines(y=exp(fitted(mcapermute1)-1),x=Salmon[,"Position"])
plot(x=Salmon[,"Abundance"],y=exp(fitted(mcapermute1)-1),asp=1,xlim=c(0,14),ylim=c(0,14),
     xlab="Observed abundance",ylab="Fitted abundance")
abline(0,1)
residuals(mcapermute1)
#
### Example 2: Oribatid mites in Lake Cromwell, Quebec, Canada.
#
## Requires package vegan
library(vegan)
data(mite.xy)
map <- eigenmap(x=as.matrix(mite.xy),truncate=c(0,NA),wf="Drayf1")
data(mite)
data(mite.env)
mca2 <- MCA(y=log(mite[,"LRUG"]+1),x=mite.env[,"WatrCont"],emobj=map)
mca2
mcapermute2 <- permute.mca(mca2)
summary(mcapermute2)
#
layout(matrix(1:2,1,2))
obs <- 0.5+log(mite[,"LRUG"]+1)/2
plot(y~x,data=mite.xy, asp=1, pch=21, cex=obs, bg="black",main="Observed")
fit <- 0.5+fitted(mcapermute2)/2
plot(y~x,data=mite.xy, asp=1, pch=21, cex=fit, bg="black",main="Fitted")
#
layout(1)
plot(x=log(mite[,"LRUG"]+1),y=fitted(mcapermute2),asp=1,xlim=c(0,7),ylim=c(0,7),
     xlab="Observed abundance (log(x+1))",ylab="Fitted abundance (log(x+1))")
abline(0,1)
#

Run the code above in your browser using DataLab