[R] extracting the first few eigenvectors

Yixuan Qiu yixuan.qiu at cos.name
Fri May 2 14:34:55 CEST 2014


Exactly.
The syntax is intended to mimic eigs() in Matlab and Octave.

library(rARPACK)
eigs(X, 10)           # If your X is of class "dsyMatrix"
eigs_sym(X, 10)   # If X is of class "matrix"


Best,
Yixuan

2014-05-02 4:48 GMT-04:00 Berend Hasselman <bhh at xs4all.nl>:
>
> 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.
>
> ______________________________________________
> 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.



-- 
Yixuan Qiu <yixuan.qiu at cos.name>
Department of Statistics,
Purdue University



More information about the R-help mailing list