From: Kenn Konstabel <lebatsnok_at_gmail.com>

Date: Fri, 16 May 2008 19:04:47 +0300

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 16 May 2008 - 17:02:59 GMT

Date: Fri, 16 May 2008 19:04:47 +0300

I'm not an expert at all, but isn't it that you really want svd(x)$u to be different (instead of V)?

that would be easy to do:

x <- matrix(rnorm(15), 3, 5)

s1 <- svd(x)

s2 <- svd(x, nv=ncol(x))

x1 <- s1$u %*% diag(s1$d) %*% t(s1$v)

x2 <- cbind(s2$u,1,1) %*% diag(c(s1$d,0,0)) %*% t(s2$v)

all.equal(x,x1,x2)

In other words, I would (perhaps naively) think that in your case the "missing" elements of d would be 0 anyway, and so the "missing" columns in u are of no importance. (No idea, though, if this is of any help).

Kenn

On Fri, May 16, 2008 at 2:34 PM, Gad Abraham <gabraham_at_csse.unimelb.edu.au> wrote:

*> Hi,
**>
*

> I'm trying to do PCA on a n by p wide matrix (n < p), and I'd like to get

*> more principal components than there are rows. However, svd() only returns a
**> V matrix of with n columns (instead of p) unless the argument nv=p is set
**> (prcomp calls svd without setting it). Moreover, the eigenvalues returned
**> are always min(n, p) instead of p, even if nv is set:
**>
**> > x <- matrix(rnorm(15), 3, 5)
**> > dim(svd(x)$v)
**> [1] 5 3
**> > length(svd(x)$d)
**> [1] 3
**> > dim(svd(x, nv=5)$v)
**> [1] 5 5
**> > length(svd(x, nv=5)$d)
**> [1] 3
**> >
**>
**> Is there a way of getting more PCs and eigenvalues than rows? Is the
**> eigen-decomposition of the covariance matrix really that numerically bad?
**> (i.e., eigen(cov(x)) )
**>
**> Thanks,
**> Gad
**>
**> --
**> Gad Abraham
**> Dept. CSSE and NICTA
**> The University of Melbourne
**> Parkville 3010, Victoria, Australia
**> email: gabraham_at_csse.unimelb.edu.au
**> web: http://www.csse.unimelb.edu.au/~gabraham<http://www.csse.unimelb.edu.au/%7Egabraham>
**>
**> ______________________________________________
**> R-help_at_r-project.org mailing list
**> https://stat.ethz.ch/mailman/listinfo/r-help
**> PLEASE do read the posting guide
**> http://www.R-project.org/posting-guide.html
**> and provide commented, minimal, self-contained, reproducible code.
**>
*

[[alternative HTML version deleted]]

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 16 May 2008 - 17:02:59 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Sat 17 May 2008 - 02:30:38 GMT.