Suvarna Garge (Editor)

Canonical correlation

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Canonical correlation

In statistics, canonical-correlation analysis (CCA) is a way of making sense of 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 the Xi and Yj which have maximum correlation with each other. T. R. Knapp notes "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.

Contents

Definition

Given two column vectors X = ( x 1 , , x n ) and Y = ( y 1 , , y m ) of random variables with finite second moments, one may define the cross-covariance Σ X Y = cov ( X , Y ) to be the n × m matrix whose ( i , j ) entry is the covariance cov ( x i , y j ) . 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 vectors a and b such that the random variables a X and b Y maximize the correlation ρ = corr ( a X , b Y ) . The random variables U = a X and V = b Y 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.

Derivation

Let Σ X X = cov ( X , X ) and Σ Y Y = cov ( Y , Y ) . The parameter to maximize is

ρ = a Σ X Y b a Σ X X a b Σ Y Y b .

The first step is to define a change of basis and define

c = Σ X X 1 / 2 a , d = Σ Y Y 1 / 2 b .

And thus we have

ρ = c Σ X X 1 / 2 Σ X Y Σ Y Y 1 / 2 d c c d d .

By the Cauchy-Schwarz inequality, we have

( c Σ X X 1 / 2 Σ X Y Σ Y Y 1 / 2 ) d ( c Σ X X 1 / 2 Σ X Y Σ Y Y 1 / 2 Σ Y Y 1 / 2 Σ Y X Σ X X 1 / 2 c ) 1 / 2 ( d d ) 1 / 2 , ρ ( c Σ X X 1 / 2 Σ X Y Σ Y Y 1 Σ Y X Σ X X 1 / 2 c ) 1 / 2 ( c c ) 1 / 2 .

There is equality if the vectors d and Σ Y Y 1 / 2 Σ Y X Σ X X 1 / 2 c are collinear. In addition, the maximum of correlation is attained if c is the eigenvector with the maximum eigenvalue for the matrix Σ X X 1 / 2 Σ X Y Σ Y Y 1 Σ Y X Σ X X 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.

Solution

The solution is therefore:

  • c is an eigenvector of Σ X X 1 / 2 Σ X Y Σ Y Y 1 Σ Y X Σ X X 1 / 2
  • d is proportional to Σ Y Y 1 / 2 Σ Y X Σ X X 1 / 2 c
  • Reciprocally, there is also:

  • d is an eigenvector of Σ Y Y 1 / 2 Σ Y X Σ X X 1 Σ X Y Σ Y Y 1 / 2
  • c is proportional to Σ X X 1 / 2 Σ X Y Σ Y Y 1 / 2 d
  • Reversing the change of coordinates, we have that

  • a is an eigenvector of Σ X X 1 Σ X Y Σ Y Y 1 Σ Y X
  • b is an eigenvector of Σ Y Y 1 Σ Y X Σ X X 1 Σ X Y
  • a is proportional to Σ X X 1 Σ X Y b
  • b is proportional to Σ Y Y 1 Σ Y X a
  • The canonical variables are defined by:

    U = c Σ X X 1 / 2 X = a X V = d Σ Y Y 1 / 2 Y = b Y

    Implementation

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

  • MATLAB as canoncorr
  • R as cancor or in FactoMineR or in CCP
  • SAS as proc cancorr
  • Scikit-Learn, Python as Cross decomposition
  • SPSS ; as macro CanCorr shipped with the main software
  • 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 i th row, the test statistic is:

    χ 2 = ( p 1 1 2 ( m + n + 1 ) ) ln j = i min { m , n } ( 1 ρ ^ j 2 ) ,

    which is asymptotically distributed as a chi-squared with ( m i + 1 ) ( n i + 1 ) degrees of freedom for large p . Since all the correlations from min { m , n } to p are logically zero (and estimated that way also) the product for the terms after this point is irrelevant.

    Practical uses

    A typical use for canonical correlation in the experimental context is to take two sets of variables and see what is common amongst the two sets. For example, in psychological testing, you could take two well established multidimensional personality tests such as the Minnesota Multiphasic Personality Inventory (MMPI-2) and the NEO. By seeing how the MMPI-2 factors relate to the NEO factors, you could gain insight into what dimensions were common between the tests and how much variance was shared. For example, you might find that an extraversion or neuroticism dimension accounted for a substantial amount of shared variance between the two tests.

    One can also use canonical-correlation analysis to produce a model equation which relates two sets of variables, for example a set of performance measures and a set of explanatory variables, or a set of outputs and set of inputs. Constraint restrictions can be imposed on such a model to ensure it reflects theoretical requirements or intuitively obvious conditions. This type of model is known as a maximum correlation model.

    Visualization of the results of canonical correlation is usually through bar plots of the coefficients of the two sets of variables for the pairs of canonical variates showing significant correlation. Some authors suggest that they are best visualized by plotting them as heliographs, a circular format with ray like bars, with each half representing the two sets of variables.

    Examples

    Let X = x 1 with zero expected value, i.e., E ( X ) = 0 . If Y = X , i.e., X and Y are perfectly correlated, then, e.g., a = 1 and b = 1 , so that the first (and only in this example) pair of canonical variables is U = X and V = Y = X . If Y = X , i.e., X and Y are perfectly anticorrelated, then, e.g., a = 1 and b = 1 , so that the first (and only in this example) pair of canonical variables is U = X and V = Y = X . We notice that in both cases U = V , which illustrates that the canonical-correlation analysis treats correlated and anticorrelated variables similarly.

    Connection to principal angles

    Assuming that X = ( x 1 , , x n ) and Y = ( y 1 , , y m ) have zero expected values, i.e., E ( X ) = E ( Y ) = 0 , their covariance matrices Σ X X = Cov ( X , X ) = E [ X X ] and Σ Y Y = Cov ( Y , Y ) = E [ Y Y ] can be viewed as Gram matrices in an inner product for the entries of X and Y , correspondingly. In this interpretation, the random variables, entries x i of X and y j of Y are treated as elements of a vector space with an inner product given by the covariance cov ( x i , y j ) , see Covariance#Relationship to inner products.

    The definition of the canonical variables U and V is then equivalent to the definition of principal vectors for the pair of subspaces spanned by the entries of X and Y with respect to this inner product. The canonical correlations corr ( U , V ) is equal to the cosine of principal angles.

    References

    Canonical correlation Wikipedia