[R] Matrix Problem

Douglas Bates dmbates at gmail.com
Fri Dec 9 14:41:14 CET 2005

On 12/9/05, Nicola Salvati <hac6 at yahoo.it> wrote:
> Hello R-Users,
>   I have to invert a matrix 3000X3000 and the solve method doesn't work or it is too slow.
>   Are there any methods to invert a big matrix?

Well, first you figure out what you really need to do.  Although we
often write formulas involving a matrix inverse it is rarely necessary
to invert a matrix.  If you are simply going to solve a linear system
of equations you decompose the matrix appropriately then solve the
system or systems.  Inverting a 3000x3000 matrix is equivalent to
solving 3000 systems of equations involving the matrix.  The overhead
of creating the decomposition will be present in both cases but the
process of determining the solution for 1 system is much faster than
determining the solution of 3000 systems.

When you have a 3x3 matrix or even a 30x30 matrix the distinction
between solving a system and inverting a matrix is not that important.
 When you have a 3000x3000 matrix it is important.

Also, is the matrix symmetric? Positive definite? Sparse?  Any of
these characteristics can affect the choice of how to perform the
calculation efficiently.

More information about the R-help mailing list