[R] Q: Problems with eigen() vs. svd()

Bill Venables Bill.Venables at cmis.csiro.au
Wed May 10 13:27:49 CEST 2000


At 01:37 PM 5/10/00 +0200, ralle wrote:
>Hi,
>I have a problem understanding what is going on with eigen() for
>nonsymmetric matrices.
>Example:
>h<-rnorm(6)
>> dim(h)<-c(2,3)
>> c<-rnorm(6)

"c" is not a great choice of identifier!

>> dim(c)<-c(3,2)
>> Pi<-h %*% c
>> eigen(Pi)$values
>[1] 1.56216542 0.07147773

These could have been complex, of course, but as it happens they are real.

>> svd(Pi)$d     
>[1] 2.85537780 0.03910517

These must be real and they are not the eigenvalues of Pi.

>
>And now:
>> Pi2<-Pi %*% t(Pi) #that means Pi2 is symmetric and the eigenvalues
should be the
>		    # squared eigenvalues of Pi

Not quite.  It means Pi2 is symmetric all right, but it implies no simple
relationship between the eigenvalues of Pi and Pi2.

What you can say is the the *singular values* of Pi2 are the square of the
*singular values* of Pi.


>> eigen(Pi2)$values
>[1] 8.153182389 0.001529214
>> svd(Pi2)$d     
>[1] 8.153182389 0.001529214
>Indeed:
>diag(svd(Pi)$d) %*% diag(svd(Pi)$d)
>         [,1]        [,2]
>[1,] 8.153182 0.000000000
>[2,] 0.000000 0.001529214
>

Moral: for any real matrix X the singular values are the positive square
roots of the eigen values of t(X) %*% X.  (Consequence: if X is symmetric
and positive definite its eigenvalues are the same as its singular values,
but otherwise this is not necessarily so.)

>I conclude that eigen() works correctly for symmetric matrices only (or
>makes sense ...).

Nope.

>Do I have misconceptions about the relationship between the results of
>eigen()$values and
>svd()$d and my conclusion is wrong ?

You do have some serious misconceptions.

>The VR-Book "Modern Applied Statistics" (1994) states explicitly that
>eigen() is for
>symmetric matrices.
>
>Can anybody help me to clarify this point ?

Well the VR-book in 1994 was written for S-PLUS only, and in 1992-3 when
that edition was written it did only work for symmetric matrices, but
S-PLUS has changed and R has come of age.  Things change fast in this
territory.  There have been two more editions of the VR-book since then
this and only this reason.

V.

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list