How to do canonical correlation analysis with regularization using matlab?

Hi, there,
I need to do CCA(canonical correlation analysis) with regularization between X (n*d1 matrix) and Y (n*d2 matrix). (X and Y is not full rank.)
The regularization is defined as following, with a relatively small lambda:
  • regularized S_xx = S_xx + lambda*eye(d1)
  • regularized S_yy = S_yy + lambda*eye(d2)
I was trying to use the built-in function canoncorr, but it seemed that this function does not support this feature. I read through the code but didn't find anywhere to do the edit as the built-in function used QR decomposition.
I need this as a golden version to compare with my own. Does anybody know how to solve this problem using Matlab? Thanks!

2 Commenti

I tried the following method, but it seemed that it didn't work well enough under 'Largest principal angle'.
[Vx, Vy] = canoncorr(x, y);
Vx = Vx(:, 1:k); % get the first k component
Vy = Vy(:, 1:k);
% tried to use svd
sxx = x'*x/(n-1);
syy = y'*y/(n-1);
sxy = x'*y/(n-1);
M = sxx^(-0.5) * sxy * syy^(-0.5); % d1*d2
[Wx, ~, Wy] = svd(M);
Wx = sxx^0.5*Wx;
Wy = syy^0.5*Wy;
Wx = Wx(:, 1:k);
Wy = Wy(:, 1:k);
% =============== compare using 'Largest principal angle' =========
cos_x = calc_cos(Wx, Vx, sxx);
% it doesn't work well, only around 0.95 with n = 300, d1 =30, d2 = 30
function cos_theta = calc_cos(W, V, B)
W = GS(W,B); % Gram–Schmidt process under B-norm
V = GS(V,B);
cos_theta = min(svd(V'*B*W));
end
Sorry for bumping, I used this thread for a test only.

Accedi per commentare.

Risposte (0)

Richiesto:

il 24 Dic 2016

Commentato:

Jan
il 24 Feb 2017

Community Treasure Hunt

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

Start Hunting!

Translated by