Squared multivariate correlation between two sets of variables.
sq.correl(y, x)
A vector with two values, the trace and determinant \(R^2\).
A numerical matrix.
A numerical matrix.
Michail Tsagris
R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.
Mardia, Kent and Bibby (1979, pg. 171) defined two squared multiple correlation coefficient between the dependent variable \(\bf Y\) and the independent variable \(\bf X\). They mention that these are a similar measure of the coefficient determination in the univariate regression. Assume that the multivariate regression model is written as \({\bf Y}={\bf XB}+{\bf U}\), where \(\bf U\) is the matrix of residuals. Then, they write \({\bf D}=\left({\bf Y}^T{\bf Y}\right)^{-1}\hat{\bf U}^T\hat{\bf U}\), with \(\hat{\bf U}^T\hat{\bf U}={\bf Y}^T{\bf PY}\) and \(\bf P\) is \({\bf P}={\bf I}_n-{\bf X}\left({\bf X}^T{\bf X}\right)^{-1}{\bf X}^T\). The matrix \(\bf D\) is a generalization of \(1-R^2\) in the univariate case. Mardia, Kent and Bibby (1979, pg. 171) mentioned that the dependent variable \(\bf Y\) has to be centred.
The squared multivariate correlation should lie between 0 and 1 and this property is satisfied by the trace correlation \(r_T\) and the determinant correlation \(r_D\), defined as \(r^2_T=d^{-1}\text{tr}\left({\bf I}-{\bf D}\right)\) and \(r^2_D=\text{det}\left({\bf I}-{\bf D}\right)\) respectively, where \(d\) denotes the dimensionality of \(\bf Y\). So, high values indicate high proportion of variance of the dependent variables explained. Alternatively, one can calculate the trace and the determinant of the matrix \({\bf E}=\left({\bf Y}^T{\bf Y}\right)^{-1}\hat{\bf Y}^T\hat{\bf Y}\). Try something else also, use the function "sq.correl()" in a univariate regression example and then calculate the \(R^2\) for the same dataset. Try this example again but without centering the dependent variable. In addition, take two variables and calculate their squared correlation coefficient and then square it and using "sq.correl()".
rv, dcor
sq.correl( as.matrix(iris[, 1:2]), as.matrix(iris[, 3:4]) )
Run the code above in your browser using DataLab