Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Why is Mata much slower than MATLAB at matrix inversion?


From   Richard Herron <richard.c.herron@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Why is Mata much slower than MATLAB at matrix inversion?
Date   Fri, 20 Jul 2012 21:19:37 -0400

Snap. Yes, your m from -runiform()- will certainly be invertible.

Richard Herron


On Fri, Jul 20, 2012 at 7:14 PM, Patrick Roland
<patrick.rolande@gmail.com> wrote:
> To be clear, my point was that all Mata matrix inverse functions are
> slower than MATLAB. It does seem though that this is not true for
> small matrices (e.g. 100x100), but the difference is easily an order
> of magnitude when it comes to larger matrices (2000x2000).
>
> The fact that I compared cholinv() and a general inverse function
> should be to Mata's favor, since cholinv should presumably be faster
> if it exploits the special structure of the matrix.
>
> X'X is positive definite if X is invertible (as in my example),
> because a'X'Xa  = (Xa)'(Xa) > 0.
>
> On Fri, Jul 20, 2012 at 2:48 PM, David M. Drukker <ddrukker@stata.com> wrote:
>> Patrick Roland <patrick.rolande@gmail.com> posted that the Mata function
>> -cholinv()- is slower than a Matlab function for large matrices.
>>
>> Others have discussed some issues with Patrick's example.  Despite these
>> issues, we took Patrick's post seriously, looked at the code, and found
>> something that could be sped up.
>>
>> We will release a faster version of -cholinv()- in an upcoming executable
>> update.
>>
>> Note that any speed difference related to -cholinv()- is only noticeable for
>> large matrices.  For small matrices, such as variance-covariance matrices
>> for models with 100 or fewer parameters, the difference is much harder to
>> find.  For example, the computation takes about .001 seconds on my machine.
>>
>> Best,
>> David
>> ddrukker@stata.com
>>
>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/statalist/faq
>> *   http://www.ats.ucla.edu/stat/stata/
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index