CCorA {vegan}R Documentation

Canonical Correlation Analysis

Description

Canonical correlation analysis, following Brian McArdle's unpublished graduate course notes, plus improvements to allow the calculations in the case of very sparse and collinear matrices.

Usage

CCorA(Y, X, stand.Y=FALSE, stand.X=FALSE, nperm = 0, ...)

## S3 method for class 'CCorA':
biplot(x, xlabs, which = 1:2, ...)

Arguments

Y left matrix.
X right matrix.
stand.Y logical; should Y be standardized?
stand.X logical; should X be standardized?
nperm numeric; Number of permutations to evaluate the significance of Pillai's trace
x CCoaR result object
xlabs Row labels. The default is to use row names, NULL uses row numbers instead, and NA suppresses plotting row names completely
which 1 plots Y results, and 2 plots X1 results
... Other arguments passed to functions. biplot.CCorA passes graphical arguments to biplot and biplot.default, CCorA currently ignores extra arguments.

Details

Canonical correlation analysis (Hotelling 1936) seeks linear combinations of the variables of Y that are maximally correlated to linear combinations of the variables of X. The analysis estimates the relationships and displays them in graphs.

Algorithmic notes:

  1. All data matrices are replaced by their PCA object scores, computed by SVD.
  2. The blunt approach would be to read the three matrices, compute the covariance matrices, then the matrix S12 %*% inv(S22) %*% t(S12) %*% inv(S11). Its trace is Pillai's trace statistic.
  3. This approach may fail, however, when there is heavy multicollinearity in very sparse data matrices, as it is the case in 4th-corner inflated data matrices for example. The safe approach is to replace all data matrices by their PCA object scores.
  4. Inversion by solve is avoided. Computation of inverses is done by SVD (svd) in most cases.
  5. Regression by OLS is also avoided. Regression residuals are computed by QR decomposition (qr).

The biplot function can produce two biplots, each for the left matrix and right matrix solutions. The function passes all arguments to biplot.default, and you should consult its help page for configuring biplots.

Value

Function CCorA returns a list containing the following components:

Pillai Pillai's trace statistic = sum of canonical eigenvalues.
EigenValues Canonical eigenvalues. They are the squares of the canonical correlations.
CanCorr Canonical correlations.
Mat.ranks Ranks of matrices Y and X1 (possibly after controlling for X2).
RDA.Rsquares Bimultivariate redundancy coefficients (R-squares) of RDAs of Y|X1 and X1|Y.
RDA.adj.Rsq RDA.Rsquares adjusted for n and number of explanatory variables.
AA Scores of Y variables in Y biplot.
BB Scores of X1 variables in X1 biplot.
Cy Object scores in Y biplot.
Cx Object scores in X1 biplot.

Author(s)

Pierre Legendre, Departement de Sciences Biologiques, Universite de Montreal. Implemented in vegan with the help of Jari Oksanen.

References

Hotelling, H. 1936. Relations between two sets of variates. Biometrika 28: 321-377.

Examples

# Example using random numbers
mat1 <- matrix(rnorm(60),20,3)
mat2 <- matrix(rnorm(100),20,5)
CCorA(mat1, mat2)

# Example using intercountry life-cycle savings data, 50 countries
data(LifeCycleSavings)
pop <- LifeCycleSavings[, 2:3]
oec <- LifeCycleSavings[, -(2:3)]
out <- CCorA(pop, oec)
out
biplot(out, xlabs = NA)

[Package vegan version 1.16-32 Index]