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

From |
celdjt@umich.edu |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: RE: RE: Matrix inversion "bug" |

Date |
Tue, 10 Jun 2003 12:27:46 -0400 |

I will have to drop by on this. There was one trip charged against my account that is to be reimbursed from another. I will be back to you.

--On Tuesday, June 10, 2003 1:05 PM -0300 Ines Butler <ibutler@ieral.org> wrote:

Al, Thank you for your help. I do have more observations than variables (38 observatiosn, 10 variables). Do you have any idea why this might be happening or if there is something to do about it ? Thanks again. Regards Inés Butler IERAL Fundación Mediterránea ibutler@ieral.org <mailto:ibutler@ieral.org> www.ieral.org (54 11) 4312 4114 -----Mensaje original----- De: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu]En nombre de FEIVESON, ALAN H. (AL) (JSC-SK) (NASA) Enviado el: Tuesday, June 10, 2003 12:49 PM Para: 'statalist@hsphsun2.harvard.edu' Asunto: st: RE: RE: Matrix inversion "bug" Inés - Do you have at least as many observations as variables? If not, the matrix will not be positive definite - only semidefinite. If you have n variables, you must have at least n linearly independent observations row vectors for the accumulated matrix to be positive definite. Your problem is not the same as Mark's. If your matrix were not symmetric because of a precision error, choloesky would return the message "matrix not symmetric" instead of "matrix not positive definite". Al Feiveson -----Original Message----- From: Ines Butler [mailto:ibutler@ieral.org] Sent: Tuesday, June 10, 2003 9:45 AM To: statalist@hsphsun2.harvard.edu Subject: st: RE: Matrix inversion "bug" Mark I think I am encountering with a similar problem to the one you mention about symentric matrices. I am usingmat function 'mat accum' with the options noconstant and deviations to construct a matrix from data which should return a positive definite matrix (because divided by N-1 is the covariance matrix). However, when I try to use cholesky factorization, an error message appears saying that the matrix is not positive definite. Do you have any idea on how to cope with this problem? Thank you very much! Inés Butler IERAL Fundación Mediterránea -----Mensaje original----- De: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu]En nombre de Mark Schaffer Enviado el: Monday, June 09, 2003 8:19 PM Para: Statalist CC: Mark Schaffer Asunto: st: Matrix inversion "bug" Dear Statalisters: Every now and then I encounter a matrix inversion "bug" in Stata. It cropped up yet again last week when an ivreg2 user wrote to me, and I finally decided to see what my fellow Statalisters think of it. Say we have a matrix M which is calculated as X*S*X'. S is symmetric and so is M. We want to invert M and so the best thing to do is to use -syminv-. The Stata programming manual tells us to use -syminv- instead of -inv- wherever possible. The problem is this. Although M is guaranteed to be symmetric in principle, it is not guaranteed to be symmetric in practice. Tiny rounding errors can arise when Stata multiplies matrices. Once in a while, M will be very slightly non-symmetric, but when it is, -syminv- will exit with an error. When I first encountered this, I wrote to Stata Technical Support, and I received a very helpful and simple fix: prior to the call to syminv, simply do the following: mat M = (M+M')/2 This makes the matrix symmetric. Works, no problem. But... Arguably, this is just a fix for what is really a Stata bug. Ought it be possible for Stata's code to recognise when the result of a matrix multiplication is supposed to be a symmetric matrix? Whether or not this should be called a "bug", it may still be the case that it's not possible for our friends at Stata Corp to fix it. If so, then there are several possibilities: (1) Prior to using -syminv-, we should always (?) symmetrize the matrix we want to invert using the code fragment above. (2) Any (?) time we call -syminv-, we should use -capture-. If the inversion using -syminv- fails, we should call -inv-. (3) Neither of the above is very pretty. An alternative is to ask our Stata Corp friends to, say, add a variant of the -syminv- function, say -syminv2-. This function would automatically symmetrize a square matrix before inverting it. What do you think? --Mark ________________________________________________________________ DISCLAIMER: This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom it is addressed. If you are not the intended recipient you are prohibited from using any of the information contained in this e-mail. In such a case, please destroy all copies in your possession and notify the sender by reply e-mail. Heriot Watt University does not accept liability or responsibility for changes made to this e-mail after it was sent, or for viruses transmitted through this e-mail. Opinions, comments, conclusions and other information in this e-mail that do not relate to the official business of Heriot Watt University are not endorsed by it. ________________________________________________________________ * * 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/ * * 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/ * * 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/ * * 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/

* * 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/

**References**:**st: RE: RE: RE: Matrix inversion "bug"***From:*"Ines Butler" <ibutler@ieral.org>

- Prev by Date:
**st: RE: RE: RE: RE: Matrix inversion "bug"** - Next by Date:
**st: Sample size** - Previous by thread:
**st: RE: RE: RE: Matrix inversion "bug"** - Next by thread:
**st: RE: RE: RE: RE: Matrix inversion "bug"** - Index(es):

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