[R] General Matrix Inverse
Philippe Grosjean
phgrosje at ulb.ac.be
Thu Oct 18 09:11:54 CEST 2001
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
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list