[R] extracting the first few eigenvectors

Mike Miller mbmiller+l at gmail.com
Fri May 2 09:17:49 CEST 2014


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.

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



More information about the R-help mailing list