Canonical Correlation Analysis
A way to measure how strongly two whole groups of variables — not just two single variables — move together, by finding the best possible blend of each group to correlate against the other.
Prerequisites: The Sample Covariance Matrix and Eigenvalue Bias
Think of two sections of an orchestra rehearsing somewhat independently — the strings and the brass. You want to know how tightly the two sections are locked together musically. You could pick one violin and one trumpet and check whether they're correlated, but that's an arbitrary and probably weak signal — maybe violin 1 and trumpet 1 happen not to be the pair that's actually in sync. What you really want is: what's the best possible blend of the whole string section, and the best possible blend of the whole brass section, such that those two blended signals move together as tightly as possible? That's the question canonical correlation analysis (CCA) answers, applied to any two groups of variables — a set of macro indicators and a set of asset returns, a block of risk-factor exposures and a block of performance metrics. Instead of testing pairwise correlations one at a time, CCA finds the single best linear "chord" from each side that makes the two groups correlate as strongly as the data allows.
The idea, one symbol at a time
Let be a group of variables and be a group of variables (possibly different sizes). CCA looks for a weight vector (length ) and a weight vector (length ) that define two new single variables — the canonical variates and — chosen to maximize the correlation between and :
In words: search over every possible weighted blend of the variables and every possible weighted blend of the variables, and find the one pair of blends that correlates the most. , the first canonical correlation, is always at least as large as the biggest single pairwise correlation between any one variable and any one variable, because it's optimizing over a much larger space of possibilities. Having found that first pair, CCA then finds a second pair of blends — and — required to be uncorrelated with the first pair, that captures the next-highest remaining correlation, and so on, up to pairs total. In words: CCA doesn't stop at one relationship, it decomposes the entire cross-relationship between the two groups into a ranked sequence of independent pieces, the way principal components decompose variance within a single group into ranked independent pieces.
Worked example 1: finding the first canonical pair
Take a toy case: are two macro indicators and are two portfolio returns, all standardized to unit variance. Suppose the within-group correlations are zero (, , to keep the arithmetic clean) and the cross-correlations are , , , . The largest single pairwise correlation here is (between and ). For this clean, uncorrelated-within-group case, the canonical weights work out close to favoring and favoring for the first pair, roughly aligning -heavy and -heavy — and solving the underlying eigenvalue problem for this cross-correlation matrix gives a first canonical correlation of approximately , slightly higher than the best raw pairwise correlation of , because the optimal blend borrows a small, correctly-signed contribution from and to squeeze out a bit more shared signal.
Worked example 2: the second canonical pair
Having extracted the first pair (roughly the - relationship), CCA finds a second pair of blends, orthogonal to the first, built mostly from and — because the remaining cross-correlation structure ( with at ) is the next-strongest signal not already captured. Working through the same eigenvalue problem gives a second canonical correlation of roughly , smaller than as required (canonical correlations are always found in decreasing order), and by construction is uncorrelated with and is uncorrelated with . The result is two separate stories about how the macro block and the return block relate — one dominated by the / relationship, a second, weaker and independent one dominated by / — rather than one blurred summary number.
Canonical correlation analysis generalizes ordinary correlation from "two variables" to "two whole groups of variables": it finds the best-correlated blend from each group, then a second independent best-correlated blend from what's left, decomposing the entire cross-relationship into ranked, mutually uncorrelated pieces.
The scatter above shows what a single pairwise correlation of about the same strength as this example's first canonical correlation looks like — drag the correlation slider and watch how the point cloud tightens; canonical correlation analysis is finding the tightest possible such cloud by choosing the best blend on each axis, rather than being stuck with whatever raw variable pairing you happened to pick.
What this means in practice
- Relating factor blocks to return blocks. A common use is checking how strongly a whole set of macro or style factors comoves with a whole set of asset or strategy returns — CCA finds the specific combinations driving that relationship rather than requiring you to guess which pairwise correlation to look at.
- Dimensionality reduction before regression. When both the predictor set and the target set are multivariate, running CCA first and regressing on the leading canonical variates can be more stable and interpretable than throwing every raw variable into a giant regression.
- Cross-asset comovement analysis. Comparing a block of rates-market variables to a block of equity-market variables, or a block of on-chain metrics to a block of crypto asset returns, are natural CCA applications.
- It needs enough data. Estimating pairs of weights from a covariance-type structure across two groups is a genuinely high-dimensional estimation problem, and gets fragile quickly as and grow relative to sample size.
The classic confusion: treating the first canonical correlation as a clean summary statistic for "how correlated are these two datasets," the way summarizes how well a regression fits. It's not that simple, because CCA is actively searching over every possible linear blend of each group to maximize the correlation — and with only a modest sample size relative to the number of variables in each group, that search can find and report a large, impressive-looking canonical correlation that is substantially an artifact of overfitting rather than a real, stable relationship. Canonical correlations are notoriously prone to this kind of small-sample inflation, so out-of-sample validation of the canonical relationship matters far more here than it does for an ordinary bivariate correlation between two fixed, pre-specified variables.
Related concepts
Practice in interviews
Further reading
- Hotelling (1936), Relations Between Two Sets of Variates
- Johnson & Wichern, Applied Multivariate Statistical Analysis, ch. 10