[R] extracting the first few eigenvectors

Berend Hasselman bhh at xs4all.nl
Fri May 2 10:48:23 CEST 2014


On 02-05-2014, at 09:17, Mike Miller <mbmiller+l at gmail.com> wrote:

> I have a symmetric matrix, X, and I just want the first K eigenvectors (those associated with the K largest eigenvalues).  Clearly, this works:
> 
> eigs <- eigen( X, symmetric=TRUE )
> 
> K_eigenvectors <- eigs$vectors[ , 1:K ]
> K_eigenvalues <- eigs$values[ 1:K ]
> 
> rm(eigs)
> 
> In order to do that, I have to create the matrix eigs$vectors which is the same size as X.  Sometimes X has 100 million elements or more.  Usually I want only the first 10 eigenvectors instead of all 10,000.  Is there any R function that will allow me to extract just the few that I want?  This would be analogous to the [V,d] = eigs(X,K) function in Octave/MATLAB.
> 

You can find possibly relevant stuff with

library(sos)
findFn("eigenvalue”)

which is how I found package rARPACK, which may be exactly what you need/want.

Berend

> Best,
> Mike
> 
> -- 
> Michael B. Miller, Ph.D.
> Minnesota Center for Twin and Family Research
> Department of Psychology
> University of Minnesota
> http://scholar.google.com/citations?user=EV_phq4AAAAJ
> 
> ______________________________________________
> 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.



More information about the R-help mailing list