Statalist The Stata Listserver


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

RE: st: Storing infinite confidence intervals in Stata matrices


From   "Newson, Roger B" <[email protected]>
To   <[email protected]>
Subject   RE: st: Storing infinite confidence intervals in Stata matrices
Date   Fri, 10 Feb 2006 22:28:50 -0000

Hello All

Thanks to Vince and Jean for their prompt and helpful replies, and for
pointing me to -matlist- (which I will be studying). And sorry for
having a slight paranoia attack over what fortunately turned out to be
just a display issue. I will be sleeping on this, and framing more Mata
queries over the weekend.

Best wishes

Roger


Roger Newson
Lecturer in Medical Statistics
POSTAL ADDRESS:
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute at Imperial College London
St Mary's Campus
Norfolk Place
London W2 1PG
STREET ADDRESS:
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute at Imperial College London
47 Praed Street
Paddington
London W1 1NR
TELEPHONE: (+44) 020 7594 0939
FAX: (+44) 020 7594 0942
EMAIL: [email protected]
WEBSITE: http://www.kcl-phs.org.uk/rogernewson/
Opinions expressed are those of the author, not of the institution.


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Vince
Wiggins, StataCorp
Sent: 10 February 2006 20:15
To: [email protected]
Subject: Re: st: Storing infinite confidence intervals in Stata matrices

Roger Newson <[email protected]> notes that extremely large (near
machine precision) numbers on the diagonal of a matrix can lead to
matrices
that are displayed as symmetric, when indeed they are not.  Roger wants
to use
such near-infinite values because he has infinities to store.  

He gives the nice example,

> . matrix def matti=(1,2\3,4)
>
> . matrix list matti
>
> matti[2,2]
>     c1  c2
> r1   1   2
> r2   3   4
>
> . matrix def matti[2,2]=c(maxdouble)
>
> . matrix list matti
>
> symmetric matti[2,2]
>            c1         c2
> r1          1
> r2          3  8.99e+307

Jean Salvati <[email protected]> notes, 

> This seems to be a display issue:

and demonstrates this with,

> . di matti[1,2]
> 2

Jean is right, Roger's matrix is undamaged and -matrix list- is
basically
informing Roger that for the purposes of computation, e.g. inversion,
his
matrix is considered symmetric.  Stata needs a tolerance to tiny
discrepancies
from symmetry, because matrix computations that should lead to symmetric
results can result in slight asymmetry due to the limits of numerical
precision.

In Roger's case, we might look and say, "Gee, 3 and 2 sure like like
very
different numbers, how can that be symmetric."  Given the astronomically
large
8.99e+307 on their shared diagonal, they both indeed look the same for
matrix
inversion.  Stata's tolerance for asymmetry has been carefully tuned to
double-precision computations and -matrix list- is showing us that Stata
considers the matrix symmetric for some of those computations.

If Roger wants to see his matrix in Stata, unfiltered by Stata's
definition of
numerical symmetry, he can use -matlist-, rather than -matrix list-.
-matlist- also has many more options for controlling how the matrix is
displayed.

Roger notes that -mata- seems to treat the same matrix differently,

> This feature has got me worried. Unsurprisingly, it does not seem to
> be found in Mata matrices, [...]

What Roger is seeing is strictly a display issue.  Mata has many more
matrix
functions that does -matrix- and as such is not willing to impose a
specific
tolerance for symmetry.  Instead, Mata jumps entirely the other way when
displaying a matrix, and insists on exact symmetry before showing the
matrix
as symmetric.

We could argue that exact symmetry would be a better criterion for
-matrix
list- as well, but if nothing else, the current behaviour has history on
its
side.  Moreover, we can always use -matlist- if we prefer to see our
matrices
unfiltered.

 
-- Vince 
   [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/

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