Hints In cmdscale(), the argument add = TRUE adds a constant to the distances
to avoid negative eigenvalues. This is the Cailliez correction. In capscale(),
dbrda() and adonis2(), add = "cailliez" also produces the Cailliez
correction. Another option is add = "lingoes", which produces the Lingoes
correction. The Lingoes and Cailliez corrections are also available in functions
pcoa() {ape} and wcmdscale() {vegan}. As mentioned above, the
Lingoes correction is preferable before tests of significance in MANOVA by dbRDA.
In capscale() and dbrda(),covariables can be provided in two ways:
(1) Constraining variables and covariables can be found in the same object,
which must be a data frame, and the formula must be complete with all variables
and covariables stated explicitly; covariables can be quantitative or factors;
(2) If all covariables are quantitative (or all factors coded as dummy variables
perceived by R as quantitative, as in our object covariables above), one can
simplify the coding: the constraining variables are in a data frame, and the
covariables are in a separate object that must be of class matrix; in this case the
object can be called globally without having to detail the covariables by names.
When using raw response data, the association coefficient is determined by the
argument distance.
The results of the two analyses are slightly different because (1) the test is not
performed in the same manner and (2) the correction to make the response matrix
Euclidean is not the same.
6.3.4 A Hand-Written RDA Function
The code below is another exercise in coding matrix algebra in R; just follow the
equations.
The Code It Yourself corner #3
myRDA <- function(Y, X)
{
## 1. Preparation of the data
Y.mat <- as.matrix(Y)
Yc <- scale(Y.mat, scale = FALSE)
X.mat <- as.matrix(X)
Xcr <- scale(X.mat)
# Dimensions
n <- nrow(Y)
p <- ncol(Y)
m <- ncol(X)
6.3 Redundancy Analysis (RDA)
253
to avoid negative eigenvalues. This is the Cailliez correction. In capscale(),
dbrda() and adonis2(), add = "cailliez" also produces the Cailliez
correction. Another option is add = "lingoes", which produces the Lingoes
correction. The Lingoes and Cailliez corrections are also available in functions
pcoa() {ape} and wcmdscale() {vegan}. As mentioned above, the
Lingoes correction is preferable before tests of significance in MANOVA by dbRDA.
In capscale() and dbrda(),covariables can be provided in two ways:
(1) Constraining variables and covariables can be found in the same object,
which must be a data frame, and the formula must be complete with all variables
and covariables stated explicitly; covariables can be quantitative or factors;
(2) If all covariables are quantitative (or all factors coded as dummy variables
perceived by R as quantitative, as in our object covariables above), one can
simplify the coding: the constraining variables are in a data frame, and the
covariables are in a separate object that must be of class matrix; in this case the
object can be called globally without having to detail the covariables by names.
When using raw response data, the association coefficient is determined by the
argument distance.
The results of the two analyses are slightly different because (1) the test is not
performed in the same manner and (2) the correction to make the response matrix
Euclidean is not the same.
6.3.4 A Hand-Written RDA Function
The code below is another exercise in coding matrix algebra in R; just follow the
equations.
The Code It Yourself corner #3
myRDA <- function(Y, X)
{
## 1. Preparation of the data
Y.mat <- as.matrix(Y)
Yc <- scale(Y.mat, scale = FALSE)
X.mat <- as.matrix(X)
Xcr <- scale(X.mat)
# Dimensions
n <- nrow(Y)
p <- ncol(Y)
m <- ncol(X)
6.3 Redundancy Analysis (RDA)
253
