# [R] invert 160000x160000 matrix

Douglas Bates bates at stat.wisc.edu
Tue Aug 14 16:44:28 CEST 2007

```On 8/14/07, Jiao Yang <yj316 at gwu.edu> wrote:

> Tir,

> Thank you very much for the note.  I'm using an algorithm to analyze a data set of 400 variables and the algorithm uses the inverse of a 160000x160000 positive definite matrix.  The matrix is stored as a text file.

A meta-theorem in numerical linear algebra is that if your algorithm
involves finding the inverse of a matrix then you need a better
algorithm.  When the matrix is of size p^2 by p^2 for p variables and
you say that you need to invert it you really need a better algorithm.

You need to do a lot of reading on numerical linear algebra and a lot
of thinking about the algorithm before you can proceed.  The good news
is that you will have a lot of time to do this while you are waiting
from the result from any method that you could possibly try to do the
calculation the way you have phrased it.

> Can you please give some reference to  in-place inverse technique?  I googled it, yet did not get any good results.  Thank you for your time.
>
> Best regards,
> Jiao
>
>
> ----- Original Message -----
> From: "Patnaik, Tirthankar " <tirthankar.patnaik at citi.com>
> Date: Tuesday, August 14, 2007 2:07 am
> Subject: RE: [R] invert 160000x160000 matrix
> To: Moshe Olshansky <m_olshansky at yahoo.com>, Paul Gilbert <pgilbert at bank-banque-canada.ca>, Jiao Yang <yj316 at gwu.edu>
> Cc: r-help at stat.math.ethz.ch
>
>
> > A variety of tricks would need to be used to invert a matrix of this
> > size. If there are any other properties of the matrix that you know
> > (symmetric, positive definite, etc, sparse) then they could be useful
> > too. You could partition the matrix first, then use an in-place
> > inverse technique for each block to individually calculate the
> > blocks-inverses, then combine to get the inverse of the initial
> > matrix. Again, if the implementation is actually solving an Ax-B = 0
> > system of equations, then there are specific methods for these too,
> > like an LU decomp, for instance. You might also want to check out some
> > texts for this, like the Numerical Recipes.
> > How's the matrix stored right now?
> >
> > Best,
> > -Tir
> >
> >
> >
> > Tirthankar Patnaik
> > India Strategy
> > Citigroup Investment Research
> > +91-22-6631 9887
> >
> > For important disclosures regarding Citigroup Investment Research,
> > including with respect to any issuers mentioned herein, please refer
> > to the Citigroup Investment Research disclosure website at
> >
> >
> > > -----Original Message-----
> > > From: r-help-bounces at stat.math.ethz.ch
> > > [ On Behalf Of Moshe Olshansky
> > > Sent: Tuesday, August 14, 2007 6:40 AM
> > > To: Paul Gilbert; Jiao Yang
> > > Cc: r-help at stat.math.ethz.ch
> > > Subject: Re: [R] invert 160000x160000 matrix
> > >
> > > While inverting the matrix may be a problem, if you need to
> > > solve an equation A*x = b you do not need to invert A, there
> > > exist iterative methods which do need A or inv(A) - all you
> > > need to provide is a function that computes A*x for an
> > > arbitrary vector x.
> > > For such a large matrix this may be slow but possible.
> > >
> > > --- Paul Gilbert <pgilbert at bank-banque-canada.ca>
> > > wrote:
> > >
> > > > I don't think you can define a matrix this large in R, even if you
> >
> > > > have the memory. Then, of course, inverting it there may be other
> >
> > > > programs that have limitations.
> > > >
> > > > Paul
> > > >
> > > > Jiao Yang wrote:
> > > > > Can R invert a 160000x160000 matrix with all
> > > > positive numbers?  Thanks a lot!
> > > > >
> > > > > ______________________________________________
> > > > > R-help at stat.math.ethz.ch mailing list
> > > > >
> > > >
> > > > > and provide commented, minimal, self-contained,
> > > > reproducible code.
> > > >
> > > ==============================================================
> > > ======================
> > > >
> > > > La version française suit le texte anglais.
> > > >
> > > >
> > > --------------------------------------------------------------
> > > ----------------------
> > > >
> > > > This email may contain privileged and/or confidential
> > > > inform...{{dropped}}
> > > >
> > > > ______________________________________________
> > > > R-help at stat.math.ethz.ch mailing list
> > > >
> > > >
> > > > and provide commented, minimal, self-contained, reproducible code.
> > > >
> > >
> > > ______________________________________________
> > > R-help at stat.math.ethz.ch mailing list
> > >
> > >
> > > and provide commented, minimal, self-contained, reproducible code.
> > >
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help