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

st: Re: try the NaN (but stay away from curry)


From   baum <[email protected]>
To   [email protected]
Subject   st: Re: try the NaN (but stay away from curry)
Date   Sun, 29 Sep 2002 10:54:52 -0400

--On Sunday, September 29, 2002 2:33 Nick wrote:

The example is convincing, but note that we have
some smart behaviour elsewhere in Stata. Thus

di max(1,2.71828,3.14159,.)

yields 3.14159. The result of -max()- is missing if and
only if all its arguments are missing. I'd say that
was right, at least in the important sense that
is what is usually desired.

Now substitute NaN for missing. What should the
answer be?
It could well be exactly the same. Stata has, as Nick suggests, a good deal of sensible code that takes that which _Stata considers to be_ as missing and does appropriate things with it. For instance, summarize considers only non-missing cases when it generates summary stats. The problem comes when it is possible to include missings in a Boolean statement without realizing that you are doing so. I recently suggested to my research assistant that he could write much cleaner code if he used Booleans rather than a long string of this or this or this or that...but then the Booleans all have to have 'and variable < .' appended to get them to work properly.

The sole property of NaN at issue here is that if something is a NaN, it cannot be mistaken for (e.g.) a very large positive number, or a very large negative number, or any other numerical value. It is Not a Number, and never can be confused with one. One may argue that failure to adhere to this concept leads to inconsistency across various Stata commands, most of which behave smartly w.r.t. missings; those that do not bite you every so often, and you may not even feel it at the time. But speaking from painful experience, eventually, you will.

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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index