**Date:** Thu, 18 Sep 2008 07:28:11 -0700
**Reply-To:** sounpra@YAHOO.COM
**Sender:** "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
**From:** Song <sounpra@YAHOO.COM>
**Organization:** http://groups.google.com
**Subject:** PLS using both IML and PROC PLS
**Content-Type:** text/plain; charset=windows-1252
Hi All –

I am performing PLS using the Iris data. In the first section, I am
using PROC PLS with the following code:

proc pls data=iris method = pls (algorithm=eig) nfac=2 details;
model species = sepallength sepalwidth petallength petalwidth/
solution;
output out=outpls xscore = xscr yscore = yscr;
run;quit;

Next I wanted to compared the first two x-scores from PROC PLS by
using the singular value decomposition of the X`YY`X matrix using IML.
The following is my IML code: (Note: E and F are column centered and
normalized)

proc iml;
use iris;
read all var {species} into y;
read all var {sepallength sepalwidth petallength petalwidth} into x;

/** Column centered and normalized X matrix **/
mu = x[:,];
xdiff = x - J(nrow(x),1,1)*mu;
sig = (1/(nrow(x) - 1))*xdiff`*xdiff;
d = inv(sqrt(diag(sig)));
E = xdiff*d; /** Standardized
X matrix **/

/** Colum centered and normalized Y vector **/
muy = y[:,];
ydiff = y - J(nrow(y),1,1)*muy;
sigy = (1/(nrow(y) - 1))*ydiff`*ydiff;
dy = inv(sqrt(diag(sigy)));
F = ydiff*dy; /** Standardized Y vector **/

/** X`YY`X matrix **/
pls =E`*F*F`*E;

call svd(u,v,q,pls);
print u;

W = u[,1:2];
/** obtaining the first two x-scores **/
t = E*W;

beta1 = inv(t[,1]`*t[,1])*t[,1]`*F;
print beta1;
varnames='xscr1':'xscr2';
create PLS from t [colname=varnames];
append from t;
quit;

When I print out the U matrix ( the matrix of eigenvector for X`YY`X),
the first eigenvector is exactly the same one produced by PROC PLS
thus the first x-scores match up exactly. Also by beta1 from IML is
the same as the first "inner regression coefficients" given in the
PROC.

However the second eigenvectors do not match therefore my second x-
scores using IML are different than PROC PLS. Am I missing something
in the IML code? Should I be subtracting my first x and y-scores from
my respective matrices and recomputed the SVD my updated E`FF`E
matrix?

Any thoughts or suggestion will be much appreciated.

Thanks,
Song