R: Canonical Correlations (original) (raw)
cancor {stats} | R Documentation |
---|
Description
Compute the canonical correlations between two data matrices.
Usage
cancor(x, y, xcenter = TRUE, ycenter = TRUE)
Arguments
x | numeric matrix (n \times p_1), containing the x coordinates. |
---|---|
y | numeric matrix (n \times p_2), containing the y coordinates. |
xcenter | logical or numeric vector of length p_1, describing any centering to be done on the x values before the analysis. If TRUE (default), subtract the column means. If FALSE, do not adjust the columns. Otherwise, a vector of values to be subtracted from the columns. |
ycenter | analogous to xcenter, but for the y values. |
Details
The canonical correlation analysis seeks linear combinations of they
variables which are well explained by linear combinations of the x
variables. The relationship is symmetric as ‘well explained’ is measured by correlations.
Value
A list containing the following components:
cor | correlations. |
---|---|
xcoef | estimated coefficients for the x variables. |
ycoef | estimated coefficients for the y variables. |
xcenter | the values used to adjust the x variables. |
ycenter | the values used to adjust the x variables. |
References
Becker RA, Chambers JM, Wilks AR (1988).The New S Language. Chapman and Hall/CRC, London.
Hotelling H (1936). “Relations Between Two Sets of Variates.”Biometrika, 28(3–4), 321–377.doi:10.1093/biomet/28.3-4.321.
Seber GAF (1984).Multivariate Observations. Wiley, New York.doi:10.1002/9780470316641. Page 506f.
See Also
[qr](../../base/html/qr.html)
, [svd](../../base/html/svd.html)
.
Examples
## signs of results are random
pop <- LifeCycleSavings[, 2:3]
oec <- LifeCycleSavings[, -(2:3)]
cancor(pop, oec)
x <- matrix(rnorm(150), 50, 3)
y <- matrix(rnorm(250), 50, 5)
(cxy <- cancor(x, y))
all(abs(cor(x %*% cxy$xcoef,
y %*% cxy$ycoef)[,1:3] - diag(cxy $ cor)) < 1e-15)
all(abs(cor(x %*% cxy$xcoef) - diag(3)) < 1e-15)
all(abs(cor(y %*% cxy$ycoef) - diag(5)) < 1e-15)
[Package _stats_ version 4.6.0 Index]