Hi All

Since few days I am trying to figure out what in my derivation of the loadings matrix 
does 
not work. The question is most likely how the matrix of eigenvectors needs to be 
scaled 
(and how to scale them) in order that the loadings matrix comes out right. In the code 
below, the eigenvalues seem correct since SAS's proc cancorr also gives me these 
values 
that I get from calculating them manually with SAS/IML.

read all var {PENET PCYCLE PRICE PVTSH PURHH} into X;                           /*the 
IV*/
read all var {FEAT DISP PCUT SCOUP MCOUP} into Y;                       /*the 
dependents*/
n = nrow (X);
o = nrow (Y);                                                /*same as n in this 
dataset*/
p = ncol (X);
q = ncol (Y);                                                /*same as p in this 
dataset*/
J = shape (1, n, n);
K = shape (1, o, o);
Xd = X - (J / n)` * X;
Sx = (1 / (n - 1)) * Xd` * Xd;
Xs = Xd * (sqrt (diag (Sx))` ** (-1))`;                   /*n x p standardized IV 
matrix*/
Yd = Y - (J / o)` * Y;
Sy = (1 / (o - 1)) * Yd` * Yd;
Ys = Yd * (sqrt (diag (Sy))` ** (-1))`;                   /*o x q standardized DV 
matrix*/
reset print;
Rxx = (1 / (n - 1)) * Xs` * Xs;
Rxy = (1 / (n - 1)) * Xs` * Ys;
Ryy = (1 / (n - 1)) * Ys` * Ys;
Ryx = (1 / (n - 1)) * Ys` * Xs;                             /*p x p correlation 
matrices*/
A = eigvec (Rxx ** (-1) * Rxy * Ryy ** (-1) * Ryx);
B = eigvec (Ryy ** (-1) * Ryx * Rxx ** (-1) * Rxy);       /*p x p matrix of 
eigenvectors*/
aa = eigval (Rxx ** (-1) * Rxy * Ryy ** (-1) * Ryx);
Da = sqrt (diag (aa[1:p, 1]));
bb = eigval (Ryy ** (-1) * Ryx * Rxx ** (-1) * Rxy);
Db = sqrt (diag (bb[1:p, 1]));  /*p x p diag matrix of canonical correlations same as 
Da*/
reset noprint;
U = Xs * B;
T = Ys * A;                                         /*n x p matrix of canonical 
variates*/
reset print;
F = Rxx * B;
G = Ryy * A;       /*p x p canonical loadings where A and B probably need to be 
rescaled*/
/*F = (1 / (n - 1)) * Xs` * U;*/
/*G = (1 / (n - 1)) * Ys` * T;*/            /*where U and T probably need to be 
rescaled*/
/*F = (1 / (n - 1)) * Xs` * Xs * B;*/
/*G = (1 / (n - 1)) * Ys` * Ys * A;*/            /*F and G can also be computed this 
way*/




I really would appreciate your help. Thanks in advance.

Bye Toby






John describes canonical correlation also, but does not mention how the eigenvectors 
are 
scaled to yield the canonical weights.
http://www.biostat.wustl.edu/archives/html/s-news/1999-01/msg00104.html

.
.
=================================================================
Instructions for joining and leaving this list, remarks about the
problem of INAPPROPRIATE MESSAGES, and archives are available at:
.                  http://jse.stat.ncsu.edu/                    .
=================================================================

Reply via email to