Canonical correlation analysis - remove canonical variates from data X

4 views (last 30 days)
Hello,
I'm working through canonical correlation analysis and would like to understand whether/how this apply for removing sources from the data input X.
Following this matlab example: (https://se.mathworks.com/help/stats/canoncorr.html)
load carbig;
data = [Displacement Horsepower Weight Acceleration MPG];
nans = sum(isnan(data),2) > 0;
X = data(~nans,1:3);
Y = data(~nans,4:5);
[A,B,r,U,V] = canoncorr(X,Y);
Is it possible to project our the first sources in U from the data matrix X? I am used to doing this with pca - project out sources - but have not understood how to do it with canoncorr, or if it is possible.
Usually from my reduced rank data X, U will have less canonical components than X there are columns in X.
Any help is appreciated.

Answers (1)

Nithin
Nithin on 9 Apr 2025 at 4:16
Unlike PCA, Canonical Correlation Analysis (CCA) does not inherently provide a straightforward method to "project out" certain components from the original data matrix "X". In PCA, you can project out certain components by reconstructing the data without those components. However in CCA, the focus is on the relationships between the two sets of variables rather than on reducing dimensionality within a single dataset. Refer to the following documentation to know more about CCA: https://www.mathworks.com/help/stats/canoncorr.html
Though this is not a standard application of CCA, you can attempt to use the canonical variables to adjust your data. Refer to the following steps to understand the general approach:
  • Compute the canonical coefficients "A" and "B" for the datasets "X" and "Y", respectively. This will give you the canonical variables "U = XA" and "V = YB".
  • Decide which canonical components you want to remove. For instance, you might want to remove the influence of the first few canonical variables in "U".
  • Since CCA does not provide a direct method for reconstructing "X" like PCA does, you could attempt a workaround by adjusting "X" based on the canonical variables. However, this is not straightforward and might involve custom calculations on computing the contribution of the canonical variables you wish to remove and adjusting "X" by subtracting these contributions.
  • You can also explore using the canonical coefficients "A" to transform "X" into a space where the unwanted components have less influence, though this won't be a direct removal.

Categories

Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!