# [R] General Matrix Inverse

Gerard.Keogh@cso.ie Gerard.Keogh at cso.ie
Thu Oct 18 13:45:35 CEST 2001

```Generalised Inverse:

The Moore-Penrose Generalisied Inverse is probably better defined as a
pseudo-Inverse that arises in solving least squares problems.
Another well known pseudo-Inverse is the so-called Drazin pseudo-Inverse.
If memory serves (and it's been 10-12 years!) it can be obtained via a
diagonalisation.

Anyway, I dare say Prof. Ripley (among others) probably has "all the
low-down" on this stuff.

Gerard

Torsten Hothorn
<Torsten.Hothorn at rzmail.uni-er        To:     Philippe Grosjean <phgrosje at ulb.ac.be>
langen.de>                            cc:     r-help at stat.math.ethz.ch
Sent by:                              Subject:     RE: [R] General Matrix Inverse
owner-r-help at stat.math.ethz.ch

18/10/01 08:52

> I use solve(x) to find the inverse of a matrix (don't know what a
"general
> inverse" is). By the way, what is better: solve(x), qr.solve(x) or
ginv(x)?
> ginv(x) seems to give results for matrices where solve and qr.solve
return
> an error:
>
> > x <- matrix(1:9, 3, 3)
> > x
>      [,1] [,2] [,3]
> [1,]    1    4    7
> [2,]    2    5    8
> [3,]    3    6    9
> > solve(x)
> Error in solve.default(x) : singular matrix `x' in solve
> > qr.solve(x)
> Error in qr.solve(x) : singular matrix `x' in solve
> > ginv(x)
>            [,1]          [,2]       [,3]
> [1,] -0.6388889 -5.555556e-02  0.5277778
> [2,] -0.1666667  4.163336e-17  0.1666667
> [3,]  0.3055556  5.555556e-02 -0.1944444
>

if A is singular, A^-1 is not defined but a generalized inverse G is,
namely

G is generalized inverse of A <=>

A G A = A  (sometimes G is written as A^-)

G is not unique, but adding 3 conditions

- G A G = G

- t(G A) = G A

- t(A G) = A G

makes G unique (Moore-Penrose-Inverse)

Torsten

> Regards,
>
> Philippe Grosjean
>
>
> ...........]<(({?<...............<?}))><...............................
>  ) ) ) ) )          __                        __
> ( ( ( ( (          |__)                      |  _
>  ) ) ) ) )         |   hilippe               |__)rosjean
> ( ( ( ( (          Marine Biol. Lab., ULB, Belgium
>  ) ) ) ) )                                    __
> ( ( ( ( (          |\  /|                    |__)
>  ) ) ) ) )         | \/ |ariculture &        |__)iostatistics
> ( ( ( ( (
>  ) ) ) ) )         e-mail: phgrosje at ulb.ac.be or phgrosjean at sciviews.org
> ( ( ( ( (          SciViews project coordinator (http://www.sciviews.org)
>  ) ) ) ) )      tel: 00-32-2-650.29.70 (lab), 00-32-2-673.31.33 (home)
> ( ( ( ( (
>  ) ) ) ) )      "I'm 100% confident that p is between 0 and 1"
> ( ( ( ( (                                  L. Gonick & W. Smith (1993)
>  ) ) ) ) )
> .......................................................................
>
>
> -----Message d'origine-----
> De : owner-r-help at stat.math.ethz.ch
> [mailto:owner-r-help at stat.math.ethz.ch]De la part de Prof Brian Ripley
> Envoye : jeudi 18 octobre 2001 04:25
> A : Randall Skelton
> Cc : r-help at stat.math.ethz.ch
> Objet : Re: [R] General Matrix Inverse
>
>
> On Wed, 17 Oct 2001, Randall Skelton wrote:
>
> > What is the easiest (not the fastest) way to find the general inverse
of a
> > matrix in R?
>
> If you mean the generalized inverse, ginv() in package MASS.  Otherwise,
> pleae tell us what a `general inverse' is.
>
>
> --
> Brian D. Ripley,                  ripley at stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272860 (secr)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.
> -.-
> r-help mailing list -- Read
http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._.
> _._
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-.-
> r-help mailing list -- Read
http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._._._
>

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._._

The information in this email, and any attachments transmitted with it, are confidential
and are for the intended recipient only. If you receive this message in error, please
notify us via postmaster at cso.ie.

To see the latest figures from the CSO go to http://www.cso.ie
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```