function [R,P,T]=simpls(X,y,h) %SIMPLS algorithm for univariate y %input: %X: data matrix, %y: class labels, %h: number of components %output: % T: PLS components matrix % R: PLS weight matrix such that T=XR % P: PLS loading matrix such that X=TP' %Updated on 04/01/2009 T=zeros(size(X,1),h); R=zeros(size(X,2),h); V=R; s=X'*y; for i=1:h r=s; t=X*r; t=t-T(:,1:max(1,i-1))*(T(:,1:max(1,i-1))'* t); normt=sqrt(t'*t); t=t/normt; r=r/normt; p=X'*t; v=p-V(:,1:max(1,i-1))*(V(:,1:max(1,i-1))'*p); v=v/sqrt(v'*v); s=s-v*(v'*s); T(:,i)=t; R(:,i)=r; P(:,i)=p; V(:,i)=v; end;