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

st: Re: NaN (the inedible kind)


From   Christopher F Baum <baum@bc.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Re: NaN (the inedible kind)
Date   Thu, 26 Sep 2002 08:18:13 -0400

--On Thursday, September 26, 2002 2:33 -0400 Roger wrote:

What precisely is a NaN? And does it have any connection with missing
values, or with the "magic number" 1e300 mentioned in -[R] tabstat-? I
can't find any reference to NaNs in -[R] matrix define-.
NaN is geekspeak for Not a Number. See

http://www.psc.edu/general/software/packages/ieee/ieee.html

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.

Kit *
* 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index