ArticleslgStudy

science

Canonical correlation

Canonical correlation is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Canonical correlation rather than just read about it. In short: In statistics, canonical-correlation analysis (CCA), also called canonical variates analysis, is a way of inferring information from cross-covariance matrices. If we have two vectors X = (X1, ..., Xn) and Y = (Y1, ..., Ym) of random variables, and there are correlations among the variables, then canonical-correlation analysis will find linear combinations of X and Y that have a maximum correlation with each other.

Key takeaways

  • Canonical correlation belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Canonical correlation to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Canonical correlation from memory before moving on to harder problems.

Reference excerpt

In statistics, canonical-correlation analysis (CCA), also called canonical variates analysis, is a way of inferring information from cross-covariance matrices. If we have two vectors X = (X1, ..., Xn) and Y = (Y1, ..., Ym) of random variables, and there are correlations among the variables, then canonical-correlation analysis will find linear combinations of X and Y that have a maximum correlation with each other. T. R. Knapp notes that "virtually all of the commonly encountered parametric tests of significance can be treated as special cases of canonical-correlation analysis, which is the general procedure for investigating the relationships between two sets of variables." The method was first introduced by Harold Hotelling in 1936, although in the context of angles between flats the mathematical concept was published by Camille Jordan in 1875. CCA is important in multivariate statistics and multi-view learning, and a number of interpretations and extensions have been proposed, such as probabilistic CCA, sparse CCA, multi-view CCA, deep CCA, and DeepGeoCCA. Literature on the subject can on occasion be inconsistent with notation. These inconsistencies are noted in this article to help the reader make best use of the existing literature and techniques available. Like its sister method PCA, CCA can be viewed in population form (corresponding to random vectors and their covariance matrices) or in sample form (corresponding to datasets and their sample covariance matrices). These two forms are almost exact analogues of each other, which is why their distinction is often overlooked, but they can behave very differently in high dimensional settings. We next give explicit mathematical definitions for the population problem and highlight the different objects in the so-called canonical decomposition - understanding the differences between these objects is crucial for interpretation of the technique.

Population CCA definition via correlations Given two column vectors X=(x1,…,xn)T and Y=(y1,…,ym)T of random variables with finite second moments, one may define the cross-covariance ΣXY=cov⁡(X,Y) to be the n×m matrix whose (i,j) entry is the covariance cov⁡(xi,yj). In practice, we would estimate the covariance matrix based on sampled data from X and Y (i.e. from a pair of data matrices). Canonical-correlation analysis seeks a sequence of vectors ak (ak∈ℝn) and bk (bk∈ℝm) such that the random variables akTX and bkTY maximize the correlation ρ=corr⁡(akTX,bkTY). The (scalar) random variables U=a1TX and V=b1TY are the first pair of canonical variables. Then one seeks vectors maximizing the same correlation subject to the constraint that they are to be uncorrelated with the first pair of canonical variables; this gives the second pair of canonical variables. This procedure may be continued up to min⁡{m,n} times.

(ak,bk)=argmaxa,bcorr⁡(aTX,bTY) subject to cov⁡(aTX,ajTX)=cov⁡(bTY,bjTY)=0 for j=1,…,k−1 The sets of vectors ak,bk are called canonical directions or weight vectors or simply weights. The 'dual' sets of vectors ΣXXak,ΣYYbk are called canonical loading vectors or simply loadings; these are often more straightforward to interpret than the weights.

Computation

Derivation Let ΣXY be the cross-covariance matrix for any pair of (vector-shaped) random variables X and Y. The target function to maximize is

ρ=aTΣXYbaTΣXXabTΣYYb. The first step is to define a change of basis and define

c=ΣXX1/2a, d=ΣYY1/2b, where ΣXX1/2 and ΣYY1/2 can be obtained from the eigen-decomposition (or by diagonalization):

ΣXX1/2=VXDX1/2VX⊤,VXDXVX⊤=ΣXX, and

ΣYY1/2=VYDY1/2VY⊤,VYDYVY⊤=ΣYY. Thus

ρ=cTΣXX−1/2ΣXYΣYY−1/2dcTcdTd. By the Cauchy–Schwarz inequality,

(cTΣXX−1/2ΣXYΣYY−1/2)(d)≤(cTΣXX−1/2ΣXYΣYY−1/2ΣYY−1/2ΣYXΣXX−1/2c)1/2(dTd)1/2, ρ≤(cTΣXX−1/2ΣXYΣYY−1ΣYXΣXX−1/2c)1/2(cTc)1/2. There is equality if the vectors d and ΣYY−1/2ΣYXΣXX−1/2c are collinear. In addition, the maximum of correlation is attained if c is the eigenvector with the maximum eigenvalue for the matrix ΣXX−1/2ΣXYΣYY−1ΣYXΣXX−1/2 (see Rayleigh quotient). The subsequent pairs are found by using eigenvalues of decreasing magnitudes. Orthogonality is guaranteed by the symmetry of the correlation matrices. Another way of viewing this computation is that c and d are the left and right singular vectors of the correlation matrix of X and Y corresponding to the highest singular value.

Solution The solution is therefore:

c is an eigenvector of ΣXX−1/2ΣXYΣYY−1ΣYXΣXX−1/2 d is proportional to ΣYY−1/2ΣYXΣXX−1/2c Reciprocally, there is also:

d is an eigenvector of ΣYY−1/2ΣYXΣXX−1ΣXYΣYY−1/2 c is proportional to ΣXX−1/2ΣXYΣYY−1/2d Reversing the change of coordinates, we have that

a is an eigenvector of ΣXX−1ΣXYΣYY−1ΣYX, b is proportional to ΣYY−1ΣYXa; b is an eigenvector of ΣYY−1ΣYXΣXX−1ΣXY, a is proportional to ΣXX−1ΣXYb. The canonical variables are defined by:

U=cTΣXX−1/2X=aTX V=dTΣYY−1/2Y=bTY

Implementation CCA can be computed using singular value decomposition on a correlation matrix. It is available as a function in

MATLAB as canoncorr (also in Octave) R as the standard function cancor and several other packages, including candisc, CCA and vegan. CCP for statistical hypothesis testing in canonical correlation analysis. SAS as proc cancorr Python in the library scikit-learn, as cross decomposition and in statsmodels, as CanCorr. The CCA-Zoo library implements CCA extensions, such as probabilistic CCA, sparse CCA, multi-view CCA, and deep CCA. SPSS as macro CanCorr shipped with the main software Julia (programming language) in the MultivariateStats.jl package. CCA computation using singular value decomposition on a correlation matrix is related to the cosine of the angles between flats. The cosine function is ill-conditioned for small angles, leading to very inaccurate computation of highly correlated principal vectors in finite precision computer arithmetic. To fix this trouble, alternative algorithms are available in

SciPy as linear-algebra function subspace_angles MATLAB as FileExchange function subspacea

Hypothesis testing Each row can be tested for significance with the following method. Since the correlations are sorted, saying that row i is zero implies all further correlations are also zero. If we have p independent observations in a sample and ρ^i is the estimated correlation for i=1,…,min⁡{m,n}. For the ith row, the test statistic is:

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Canonical correlation

Start with the simplest possible case. Write down what Canonical correlation claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Canonical correlation before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Canonical correlation ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Canonical correlation

In research
Canonical correlation appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Canonical correlation in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Canonical correlation is common in secondary-school and first-year university syllabi. It links to neighbouring topics Covariance and correlation, so understanding it makes those chapters shorter.
In everyday life
Look for Canonical correlation outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Canonical correlation” →

How to study Canonical correlation in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Canonical correlation means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Canonical correlation out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Canonical correlation in simple terms?

In statistics, canonical-correlation analysis (CCA), also called canonical variates analysis, is a way of inferring information from cross-covariance matrices. If we have two vectors X = (X1, ..., Xn) and Y = (Y1, ..., Ym) of random variables, and there are correlations among the variables, then ca…

Why does Canonical correlation matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Canonical correlation?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Canonical correlation.

Tags

  • Covariance and correlation

Keep exploring