Subject: Re: [R] Matrix inverse
From: Alberto Murta (amurta@ipimar.pt)
Date: Sat 29 Apr 2000 - 05:18:02 EST
Message-ID: <3909E3EA.6581ADD1@ipimar.pt>
Patrik Waldmann wrote:
>
> I haven't found a function that directly calculates the matrix inverse, does it exist? Otherwise what would be the fastest way to do it?
>
You can use solve(), or if your matrix is not square, you can calculate
the generalised inverse using the singular value decomposition function
svd().
If you have a matrix X, svd(X) will return 1 vector d and 2 matrices u
and v.
The inverse of X is then the matrix calculated as v%*%diag(1/d)%*%t(u).
If any element of vector d is 0, then replace the corresponding element
in diag(1/d) by 0.
Alberto
__________________ Alberto G. Murta ______________________
IPIMAR - Institute of Fisheries and Sea Research
Avenida de Brasilia; 1449-006 Lisboa; Portugal
Tel:351 213027062; Fax:351 213015948; http://www.ipimar.pt
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2b25 : Mon 17 Jul 2000 - 12:33:17 EST