LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (April 2003, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sat, 12 Apr 1997 20:00:55 -0300
Reply-To:   Carlos Tadeu <ctsdias@CARPA.CIAGRI.USP.BR>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Carlos Tadeu <ctsdias@CARPA.CIAGRI.USP.BR>
Subject:   Re: svd in iml again
Comments:   To: cassell.david@EPAMAIL.EPA.GOV
Content-Type:   text/plain; charset="iso-8859-1"

David, Thank you for your reply. Note that there is an inversion in the signal of the third eigenvector of U when we use eigvec function compared with U1 obtained from SVD routine (call svd). So, with the following code, which have this change, ========================================================== proc iml; reset print;

U1 ={

0.6829111 -0.729794 0.032144 0, 0.379184 0.3917486 0.838303 0, 0.6243813 0.560298 -0.5442556 0};

Q1={ 15.63108, 6.2868832, 1.0697839, 0};

V1={

0.123579 0.0621615 0.987458 0.0760974, 0.4240811 0.5518147 -0.142056 0.7039005, 0.7466757 0.2119602 -0.058408 -0.627803, 0.4973518 -0.804182 -0.036542 0.3234137}; AA=U1*diag(Q1)*T(V1);

QUIT; =========================================================

we have in output the matrix AA:

AA 3 rows 4 cols (numeric)

1.0679119 1.99023 6.9959835 8.9974851 1.7711111 3.7452081 4.8952398 0.9344588 0.8501328 6.1654201 8.0680142 2.0425536

so different of original one:

A={1 2 7 9, 0 4 5 1, 2 6 8 2};

I can not understand why the eigvec and eigval functions do not give the correct singular value decomposition. Is it a wrong calculation in this functions? Obviously, both sets of eigenvectors form an orthonormal basis, as noted by Dale (not post here). I don't know what determines whether one should employ the positive or the negative eigenvector. TIA Carlos

----- Original Message ----- From: David L. Cassell <cassell.david@EPAMAIL.EPA.GOV> Newsgroups: bit.listserv.sas-l To: <SAS-L@LISTSERV.UGA.EDU> Sent: Friday, April 11, 2003 9:01 PM Subject: Re: svd in iml again

> Carlos Tadeu <ctsdias@CARPA.CIAGRI.USP.BR> wrote: > > I am trying to do a singular value decomposition of matrix A in IML > using eigvec and eigval functions, but I can not reproduce the original > matrix A. > > What is wrong? Does anyone have had the same problem? > > I know that SVD routine operates well. It sound like inversion in the > signal of the eigvector. > > The code that I am using eigvec function is: > > proc iml; > > reset print; > > A={1 2 7 9, > > 0 4 5 1, > > 2 6 8 2}; > > n=nrow(A); > > p=ncol(A); > > AAL=A*t(A); > > ALA=t(A)*A; > > U=eigvec(AAL); > > V=eigvec(ALA); > > L=eigval(AAL); > > D=sqrt(diag(L)); > > Things are fine down to here... > > > U=U[1:3,1:3]; > > V=V[1:4,1:3]; > > Uh-oh. Here's where your code goes astray. > > Your original *square* matrices U and V are the correct matrices > for the SVD. Try using: > > call svd (U1,Q1,V1,A); > > and compare the results to your U and V matrices. > Just don't cut V (or U in the m<n case) down. > > HTH, > David > -- > David Cassell, CSC > Cassell.David@epa.gov > Senior computing specialist > mathematical statistician


Back to: Top of message | Previous page | Main SAS-L page