From the CCA Objective to an Eigenvalue Problem
Canonical correlation analysis (CCA) looks for linear combinations of two data blocks whose scores have the largest correlation. The constrained optimization formulation expresses this by choosing weight vectors with unit within-block variance and maximizing their cross-covariance. This tutorial derives the generalized eigenvalue equations that follow from that formulation and explains why their eigenvalues are squared canonical correlations.
Let \(X\) be a centered \(n\times p\) data matrix for one block and \(Y\) a centered \(n\times q\) data matrix for the other block. The rows correspond to the same \(n\) observations. Define the empirical covariance matrices using divisor \(n-1\):
Thus \(S_{xx}\) is \(p\times p\), \(S_{yy}\) is \(q\times q\), and \(S_{xy}\) is \(p\times q\). For weight vectors \(a\in\mathbb{R}^p\) and \(b\in\mathbb{R}^q\), the scores are \(Xa\) and \(Yb\). Their covariance is \(a^\top S_{xy}b\), and their variances are \(a^\top S_{xx}a\) and \(b^\top S_{yy}b\). The first CCA pair solves
The variance constraints make the objective the correlation of the two scores. The derivation below assumes \(S_{xx}\) and \(S_{yy}\) are positive definite, so both are invertible and every nonzero weight vector has positive within-block variance. This is the classical nonsingular setting; the equations need modification or special handling when a covariance matrix is singular.
Deriving Both Generalized Eigenvalue Equations
Introduce Lagrange multipliers \(\eta_x\) and \(\eta_y\) for the two variance constraints. With the objective written as a maximization, one convenient Lagrangian is
Setting the gradients with respect to \(a\) and \(b\) equal to zero gives the stationarity equations. Since the covariance matrices within each block are symmetric, differentiating each quadratic form gives:
Multiply the first equation on the left by \(a^\top\). Because \(a^\top S_{xx}a=1\), this gives \(a^\top S_{xy}b=\eta_x\). Multiplying the second equation by \(b^\top\), and using \(b^\top S_{yy}b=1\), gives \(b^\top S_{yx}a=\eta_y\). The two left sides are the same scalar because \(S_{yx}=S_{xy}^\top\). Therefore \(\eta_x=\eta_y\), and both equal the objective value. Denote this value by \(\rho\), the correlation of the normalized scores. The stationary equations become
For a nonzero \(\rho\), solve the second equation for \(b\), then substitute into the first. Since \(S_{yy}\) is invertible, \(b=\rho^{-1}S_{yy}^{-1}S_{yx}a\), so
This is the \(p\)-dimensional generalized eigenvalue problem. Eliminating \(a\) instead gives the \(q\)-dimensional counterpart:
If a canonical correlation is zero, the corresponding stationarity equations still apply; elimination by division by \(\rho\) is not available for that pair. The generalized equations themselves describe the zero eigenvalues as well.
Why the Eigenvalues Are Squared Correlations
The square appears because eliminating one weight vector substitutes an equation containing \(\rho\) into another equation that also contains \(\rho\). For example, substituting \(b=\rho^{-1}S_{yy}^{-1}S_{yx}a\) into \(S_{xy}b=\rho S_{xx}a\) yields a factor \(\rho^{-1}\) on the left and \(\rho\) on the right; multiplying through by \(\rho\) produces \(\rho^2\).
The matrix \(S_{xy}S_{yy}^{-1}S_{yx}\) is symmetric and positive semidefinite: for any \(a\), its quadratic form is \((S_{yx}a)^\top S_{yy}^{-1}(S_{yx}a)\), which is nonnegative because \(S_{yy}\) is positive definite. The generalized eigenvalues are therefore nonnegative. They are also at most 1 for a valid joint covariance matrix: every pair of score vectors has correlation with magnitude at most 1, and CCA maximizes that correlation under unit-variance constraints. Consequently \(0\leq\lambda\leq 1\), and \(\rho=\sqrt{\lambda}\) for the nonnegative canonical correlation.
A generalized eigenvector determines a direction of weights, not their absolute scale: multiplying \(a\) by a nonzero constant does not change its direction. After obtaining an eigenvector, it is normalized so that \(a^\top S_{xx}a=1\), and the associated \(b\) is normalized to satisfy \(b^\top S_{yy}b=1\). Changing the sign of one vector changes the sign of the score correlation but not its magnitude or squared value.
Worked Example: One Variable in Each Block
Suppose hypothetical centered measurements have \(S_{xx}=4\), \(S_{yy}=9\), and \(S_{xy}=3\), with the variables measured in arbitrary fixed units. Both within-block variances are positive, so the scalar covariance matrices are invertible. The joint covariance is valid because its determinant is \(4(9)-3^2=27>0\).
The \(X\)-side generalized eigenvalue equation is \(S_{xy}S_{yy}^{-1}S_{yx}a=\lambda S_{xx}a\). Substitution gives
Thus the canonical correlation is \(\rho=\sqrt{0.25}=0.5000\). Directly, the correlation is \(3/(\sqrt{4}\sqrt{9})=3/6=0.5000\), agreeing with the eigenvalue derivation. The value is dimensionless; the covariance entries have the product units of the two measurements, which cancel in the correlation.
Worked Example: Two Orthogonal Pairs of Directions
Consider hypothetical covariance blocks with \(S_{xx}=I_2\), \(S_{yy}=I_2\), and \(S_{xy}=\begin{pmatrix}0.8&0\\0&0.3\end{pmatrix}\). Both within-block covariance matrices are positive definite. The joint covariance is also positive definite: its corresponding paired directions have cross-correlations \(0.8\) and \(0.3\), both strictly between \(-1\) and \(1\).
The \(X\)-side matrix is
Because \(S_{xx}=I_2\), the generalized eigenvalues are \(0.64\) and \(0.09\). Their square roots are \(0.8000\) and \(0.3000\), so the first canonical correlation is \(0.8000\). The matching coordinate directions in the two blocks give these correlations directly. This example illustrates that eigenvalues rank the canonical pairs by squared correlation; taking the square root is necessary to report the correlation itself.
Worked Example: A Nonidentity Within-Block Covariance
Suppose hypothetical covariance matrices are \(S_{xx}=\begin{pmatrix}4&1\\1&2\end{pmatrix}\), \(S_{yy}=(9)\), and \(S_{xy}=\begin{pmatrix}3\\3\end{pmatrix}\). The determinant of \(S_{xx}\) is \(8-1=7>0\), so it is positive definite; \(S_{yy}\) is positive as well. The joint covariance is valid: \(S_{yy}-S_{yx}S_{xx}^{-1}S_{xy}=9-36/7=27/7>0\).
The matrix on the left of the generalized equation is
The generalized eigenvalues solve \(\det(S_{xy}S_{yy}^{-1}S_{yx}-\lambda S_{xx})=0\). Substituting the matrices:
The roots are \(0\) and \(4/7\). Hence the first canonical correlation is \(\sqrt{4/7}=0.7559\), and the second is zero. For the positive eigenvalue, an eigenvector is \(a=(1,3)^\top\), since \(\begin{pmatrix}1&1\\1&1\end{pmatrix}a=(4,4)^\top\) and \((4/7)S_{xx}a=(4,4)^\top\). Its variance is \(a^\top S_{xx}a=28\), so its unit-variance version is \(a/\sqrt{28}\). The squared canonical correlation is \(4/7\), not \(4/7\) itself as the correlation.
Assumptions, Diagnostics, and Alternatives
The derivation uses paired rows, centered data, the stated empirical covariance definitions, and positive-definite \(S_{xx}\) and \(S_{yy}\). Centering ensures the score covariance and variances have the usual covariance interpretation. Positive definiteness ensures the variance constraints define valid nonzero directions and permits the matrix inverses used in elimination. These are algebraic requirements for this classical derivation, not a claim that the data must follow a particular probability distribution.
When computing the equations, useful checks include:
- Confirm that \(S_{xy}\) has dimensions \(p\times q\), so the \(X\)-side product is \(p\times p\) and the \(Y\)-side product is \(q\times q\).
- Check that the within-block covariance matrices are symmetric and positive definite to the accuracy expected from the data and computation.
- Check that the resulting eigenvalues are nonnegative and no greater than 1, up to small numerical error, and that recomputed score correlations agree with their square roots.
- Check the original constraints after normalizing weights: \(a^\top S_{xx}a=1\) and \(b^\top S_{yy}b=1\).
A materially negative eigenvalue, or one materially above 1, signals a calculation or data problem, such as an incorrect covariance block, inconsistent pairing, or severe numerical error. Tiny departures can arise from rounding. If a covariance matrix is singular or nearly singular, its inverse may not exist or may amplify small perturbations. That is a limitation of the classical equations; it is not resolved by simply ignoring the problem or interpreting unstable weights as reliable. Repeated eigenvalues can also make individual weight directions nonunique even when the corresponding canonical correlations are well determined.
The constrained optimization statement is the direct conceptual definition: it makes clear which score correlation is being maximized and under what normalization. The generalized eigenvalue formulation converts that optimization into a matrix eigenproblem that can be solved using linear algebra routines. They describe the same classical solution under the assumptions above. The eigenvalue formulation is especially useful for identifying canonical correlations, while the original constrained objective remains a useful check on computed weights and scores.
Common Mistake
A frequent error is to report an eigenvalue as the canonical correlation. For example, if an eigenvalue is \(0.64\), the canonical correlation is \(\sqrt{0.64}=0.80\), not \(0.64\). The eigenvalue is the squared correlation because elimination produces \(\rho^2\). Another error is to invert a within-block covariance matrix without checking that it is nonsingular; the classical derivation requires that condition.
Check Your Understanding
Use the definitions and equations above to answer each question. Solutions are included after the problems.
- If the leading generalized eigenvalue is \(0.49\), what is the corresponding canonical correlation?
- For \(S_{xx}=(16)\), \(S_{yy}=(25)\), and \(S_{xy}=(10)\), calculate the generalized eigenvalue and canonical correlation.
- Why do the two Lagrange multipliers in the constrained derivation have the same value?
- Name two assumptions needed to obtain the classical generalized eigenvalue equations.
- A computed eigenvalue is \(1.08\). What should be concluded and checked?
Solutions. (1) The canonical correlation is \(\sqrt{0.49}=0.7000\). (2) The equation is \(10(1/25)10a=16\lambda a\), so \(4=16\lambda\), giving \(\lambda=0.25\) and \(\rho=0.5000\). (3) Multiplying each stationarity equation by its corresponding normalized weight vector shows both multipliers equal the same scalar objective, \(a^\top S_{xy}b=b^\top S_{yx}a\). (4) The data rows must be paired and centered, and both within-block covariance matrices must be positive definite; either of the latter two conditions is an acceptable assumption. (5) A value materially above 1 is not a valid squared canonical correlation in this setting. Check the covariance blocks, row pairing, matrix calculations, and numerical accuracy before interpreting the result.