Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Re: NaN (the inedible kind)


From   Roger Newson <[email protected]>
To   [email protected]
Subject   Re: st: Re: NaN (the inedible kind)
Date   Thu, 26 Sep 2002 15:23:24 +0100

At 08:18 26/09/02 -0400, Kit Baum wrote:

IMHO Stata does NOT make use of NaNs, which have the properties that missing values should have (i.e. any op involving a NaN evaluates to a NaN). If I say

use auto
g byte badrep = (rep78>3)

I get 5 obs of badrep=1 corresponding to rep78==. whereas in true NaN arithmetic they would be discarded as having no defined value. (As the IEEE std says, there are differences between three constructs, none of which can be represented in finite arithmetic: NaN, +Inf, and -Inf). To do this right in Stata, I would have to say

g byte badrep = (rep78>3 & rep78<.)

and forgetting the second clause will bite you (well, in this case maybe byte you).

Most lower-level programming languages (and some higher-level languages, e.g. Mathematica, MATLAB) support NaNs per the IEEE standard. Stata does not--it allows missing values to be treated as a very large positive number--and that has been the topic of discussion at 'wishes and grumbles' sessions at SUG meetings.

I don't know whether Bill Gould is saying that tabstat's 'magic number' behavior is inappropriate, but it is established and well defined. Nick Cox and I mimicked it in statsmat. It is very useful to be able to indicate that a certain matrix cell is not zero but rather not defined.
Thanks to Bill Gould and Kit Baum for their very informative answers to my query. If Stata ever decides to go over to supporting NaNs, then it looks like it would be a good idea also to support +Inf and -Inf as well, because these often appear in applied statistics as confidence limits (eg for odds ratios and Hodges-Lehmann median differences).

Best wishes

Roger


--
Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
or 020 7848 6605 International +44 20 7848 6605
Email: [email protected]

Opinions expressed are those of the author, not the institution.

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