[R] SVD/Eigenvector confusion
Philip Warner
pjw at rhyme.com.au
Sat Feb 28 14:47:03 CET 2004
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.
----------------------------------------------------------------
Philip Warner | __---_____
Albatross Consulting Pty. Ltd. |----/ - \
(A.B.N. 75 008 659 498) | /(@) ______---_
Tel: (+61) 0500 83 82 81 | _________ \
Fax: (+61) 03 5330 3172 | ___________ |
Http://www.rhyme.com.au | / \|
| --________--
PGP key available upon request, | /
and from pgp.mit.edu:11371 |/
More information about the R-help
mailing list