[R] solve() versus ginv()

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sun Oct 16 09:23:07 CEST 2005


Werner Bier <aliscla at yahoo.com> writes:

> Dear All,
>  
> While inverting a matrix the following error appears on my console:
>  
> Error in solve.default(my_matrix) : Lapack routine dgesv: system is exactly singular
>  
> With this respect, I have been replacing the solve() function with ginv(): the Moore-Penrose generalized inverse of a matrix. 
>  
> These are the questions I would like to ask you:
>  
> 1. Would you also replace solve() with ginv() in these scenarios and using R? 
> 2. Or is there something I should take care by using ginv() you would suggest me please? 

Well, generalized inverses work by setting 1/0 == 0, broadly speaking.
If the system has a zero eigenvalue, the r.h.s. is projected onto the
span of the matrix. (In the symmetric, positive semidefinite case,
anyway).

In statistical terms, this means that there is a direction along which
you have no information on your parameters (infinite s.e.), and the
g.inv. solves this by assuming that the effect in that direction is
zero (with zero s.e.!). This can be a sensible thing to do, but I
wouldn't be happy about having the choice made for me automatically...

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907




More information about the R-help mailing list