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 <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED]
> web: 
> http://www.csse.unimelb.edu.au/~gabraham<http://www.csse.unimelb.edu.au/%7Egabraham>
>
> ______________________________________________
> R-help@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@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.

Reply via email to