Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Dirk Enzmann <dirk.enzmann@uni-hamburg.de> |
To | statalist-digest@hsphsun2.harvard.edu |
Subject | st: Mata problem with nonreals [was: Re: Mata finds nonreal although I can't find a no nonreal] |
Date | Tue, 27 Dec 2011 13:51:24 +0100 |
"Mata rinds nonreal although I can't find a nonreal", even better: "Why does Mata report nonreals?"I still have no answer to my question but found a way to get rid of the complaint about nonreals: When inserting next to the command line that computes A1 via
A1 = S1*(V1:/sqrt(eigv1))*V1' the command line A1 = sign(P1):*abs(A1)Mata does no longer complain about the mysterious nonreals. Of course, this is no solution because this is may change the signs of the matrix elements in A1 if RF1 is not an identity matrix.
Thus, a suggestion on how to solve the problem is highly appreciated. Dirk Am 27.12.2011 04:14, schrieb Dirk Enzmann:
I just encountered the problem that Mata gives me the error message invsym(): 3253 nonreal found where real required <istmt>: - function returned error although I believe that there is no nonreal value in the matrix. Below is the code that produces the error in the line W1 = A1*invsym(A1'*A1) Note that P1, S1, and A1 should contain the same values due to the fact that RF1 is an identity matrix - if I replace A1 by P1 Mata behaves as it should. If you ask why I use RF1 like that: I am testing whether the special case of a zero correlation is handled correctly - if I insert values such as .05 in the off-diagonal cells, Mata keeps complaining about nonreal values. Any suggestions for a solution of this problem? * -------- (start) ---------- mata P1 = ( .43506, .44920 \ .68702, .06891 \ .77649, -.09335 \ -.60949, .27331 \ .02898, .65232 \ -.16600, .43717 \ .82794, -.04080 \ .79320, -.11331 \ -.04388, .62171 \ .03556, .71095 \ .08361, .75362 \ -.23253, .58472 \ .71299, -.20058 \ -.19725, .55294 \ .51660, .03276 ) RF1 = ( 1.00, .00 \ .00, 1.00 ) S1 = P1*RF1 S1 V1 = NULL eigv1 = NULL eigensystem(RF1,V1,eigv1) A1 = S1*(V1:/sqrt(eigv1))*V1' A1 rssqA1 = diagonal(A1*A1') rssqA1 cssqA1 = diagonal(A1'*A1) cssqA1 W1 = A1*invsym(A1'*A1) W1 end * -------- (end) ------------ Dirk ======================================== Dr. Dirk Enzmann Institute of Criminal Sciences Dept. of Criminology Rothenbaumchaussee 33 D-20148 Hamburg Germany phone: +49-(0)40-42838.7498 (office) +49-(0)40-42838.4591 (Mrs Billon) fax: +49-(0)40-42838.2344 email: dirk.enzmann@uni-hamburg.de http://www2.jura.uni-hamburg.de/instkrim/kriminologie/Mitarbeiter/Enzmann/Enzmann.html ========================================
-- ======================================== Dr. Dirk Enzmann Institute of Criminal Sciences Dept. of Criminology Rothenbaumchaussee 33 D-20148 Hamburg Germany phone: +49-(0)40-42838.7498 (office) +49-(0)40-42838.4591 (Mrs Billon) fax: +49-(0)40-42838.2344 email: dirk.enzmann@uni-hamburg.de http://www2.jura.uni-hamburg.de/instkrim/kriminologie/Mitarbeiter/Enzmann/Enzmann.html ======================================== * * 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/