Jonathan Greenberg
2012-Apr-19 18:50 UTC
[R] Solve an ordinary or generalized eigenvalue problem in R?
Folks: I'm trying to port some code from python over to R, and I'm running into a wall finding R code that can solve a generalized eigenvalue problem following this function model: http://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eig.html Any ideas? I don't want to call python from within R for various reasons, I'd prefer a "native" R solution if one exists. Thanks! --j -- Jonathan A. Greenberg, PhD Assistant Professor Department of Geography and Geographic Information Science University of Illinois at Urbana-Champaign 607 South Mathews Avenue, MC 150 Urbana, IL 61801 Phone: 415-763-5476 AIM: jgrn307, MSN: jgrn307@hotmail.com, Gchat: jgrn307, Skype: jgrn3007 http://www.geog.illinois.edu/people/JonathanGreenberg.html [[alternative HTML version deleted]]
Berend Hasselman
2012-Apr-20 06:37 UTC
[R] Solve an ordinary or generalized eigenvalue problem in R?
On 19-04-2012, at 20:50, Jonathan Greenberg wrote:> Folks: > > I'm trying to port some code from python over to R, and I'm running into a > wall finding R code that can solve a generalized eigenvalue problem > following this function model: > > http://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eig.html > > Any ideas? I don't want to call python from within R for various reasons, > I'd prefer a "native" R solution if one exists. Thanks!An old thread is here: http://tolstoy.newcastle.edu.au/R/help/05/06/6802.html R does provide eigen(). R has the Lapack routines dggev and dgges in its library. You'd have to write your own .Fortran interface to those routines. Berend
Luke Hartigan
2012-Apr-21 13:22 UTC
[R] Solve an ordinary or generalized eigenvalue problem in R?
Hi all, In my experience, using eigen to solve generalized eigenvalue / eigenvector problems only gives correct looking eigenvalues while the eigenvectors seem to be wrong (in comparison to results from MATLAB''s ''eig'' function for example). However, I think it is possible to solve generalized eigenvalue / eigenvectors problems in R. The way I found that works in my case is to use the simultaneous diagonalization method which is effectively two applications of the ''svd'' function. I have used this myself to get results effectively the same (down to 6th decimal place for example) as those from MATLAB. Kind regards, Luke [[alternative HTML version deleted]]
peter dalgaard
2012-Apr-21 14:40 UTC
[R] Solve an ordinary or generalized eigenvalue problem in R?
On Apr 21, 2012, at 15:22 , Luke Hartigan wrote:> Hi all, > > In my experience, using eigen to solve generalized eigenvalue / eigenvector > problems only gives correct looking eigenvalues while the eigenvectors seem > to be wrong (in comparison to results from MATLAB's 'eig' function for > example).Could you please document that? There are many misconceptions about when eigenvectors are "correct" and platform dependencies too. As far as I can tell, both R and Matlab use the same LAPACK routines. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com