Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Problem with mata: eigensystem


From   [email protected] (Jeff Pitblado, StataCorp LP)
To   [email protected]
Subject   Re: st: Problem with mata: eigensystem
Date   Fri, 21 Sep 2007 13:37:03 -0500

Karl-Oskar Lindgren <[email protected]> is using Mata's
-symeigensystem()- function to take the square root of a matrix:

> In trying to write a function to obtain the square root of a symmetric (and
> positive definite) matrix in mata (similar to matsqrt in stata) I came across
> a problem that really confuses me.

> When I try to obtain the eigenvectors and eigenvalues of a matrix of size 249
> x 249 (or smaller) all is fine, but when I try to do the same thing for a
> matrix of size  250 x 250 (or larger) I get the following error message:

>                  order():  3200  conformability error
>         _symeigen_work():     -  function returned error
>        _symeigensystem():     -  function returned error
>         symeigensystem():     -  function returned error
>                  <istmt>:     -  function returned error

> Below I provide an example that illustrates the problem (and the problem do
> occur for non-identity matrices as well). I guess I miss something really
> obvious here, either in the design of mata or in the design of
> symeigensystem and I would really appreciate if someone could explain to me
> what that something is.

> /*This is an example to illustrate the problem. Q1 works fine, but Q2
> returns the error message described above*/

> mata:
> symeigensystem(I(249), Evec1=., Eval1=.)
> symeigensystem(I(250), Evec2=., Eval2=.)
> end 

Karl-Oskar has done nothing wrong.  What he is asking of Mata should just
work, and it will after the next executable update.

Note that the only systems with this problem are big systems that also have
tied eigenvalues.

Here are the details:

Mata's -symeigensystem()- function returns the eigenvalues (and corresponding
eigenvectors) in order from largest to smallest.  When there are tied
eigenvalues, we still wanted a deterministic (and reasonable) ordering,
which is to sort (via the -order()- function) on the eigenvectors
within the tied eigenvalues.  What we didn't consider was that -order()- is
currently limited to sort on a maximum of 500 columns.  In the next executable
update, -order()- will work with an unlimited number of sort columns.

--Jeff
[email protected]
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index