[R] SVD/Eigenvector confusion

Douglas Bates bates at stat.wisc.edu
Sat Feb 28 15:01:19 CET 2004


Philip Warner <pjw at rhyme.com.au> writes:

> My understanding of SVD is that, for A an mxn matrix, m > n:
> 
>      A = UWV*
> 
> where W is square root diagonal eigenvalues of A*A extended with zero
> valued rows, and U and V are the left & right eigen vectors of A. But
> this does not seem to be strictly true and seems to require specific
> eigenvectors, and I am not at all sure how these are computed.
> 
> 
> Since W should have a zero row at the bottom, which when multiplied by
> U will just remove the last column of U, I have just omitted the last
> row of u from the outset:
> 
> 
> eg, in R:
> 
>      a <- matrix(c(c(1,2,3),c(5,14,11)),3,2)
>      u <- eigen(a %*% t(a))$vectors[,1:2]
>      v <- eigen(t(a) %*% a)$vectors
>      w <- sqrt(diag(eigen(t(a) %*% a)$values))
>      u %*% w %*% t(v)
> 
> gives:
>             [,1]       [,2]
> [1,] -0.9390078  -5.011812
> [2,] -3.3713773 -13.734403
> [3,] -1.3236615 -11.324660
> 
> which seems a little off the mark. The value for v is:
> 
>            [,1]       [,2]
> [1,] 0.1901389  0.9817572
> [2,] 0.9817572 -0.1901389
> 
> Where as svd(a)$v is:
> 
>             [,1]       [,2]
> [1,] -0.1901389  0.9817572
> [2,] -0.9817572 -0.1901389
> 
> If I substitute this in the above, I get:
> 
>      u %*% w %*% t(svd(a)$v)
> 
> which returns:
> 
>       [,1] [,2]
> [1,]    1    5
> [2,]    2   14
> [3,]    3   11
> 
> which is what the SVD should do. I assume there is some rule about
> setting the signs on eigenvectors for SVD, and would appreciate any
> help.

Eigenvectors are only known up to changes in sign.  If you want to be
more precise you can say that you determine a one-dimensional
eigenspace.  Generally we normalize the eigenvectors of a symmetric
matrix to have unit length but that still leaves you with two choices.

Is there a reason you are doing the SVD in such a complicated way?
Why not use the svd function directly?




More information about the R-help mailing list