On Tue, 13 Apr 2010, Berend Hasselman wrote:
> 2) I think that Jack's reasoning is partly correct, but not
in full
> generality: it's *not* always true that na stands for "don't know the
> exact number", sometimes it stands for "not applicable", "not a
> meaningful (numeric) value", etc. And consider the literal meaning of
> "NaN": Not a Number! The expression 0*x == 0 is only true if x *is* a
> number, which you simply don't know if you have a missing. (Often it
> will indeed be an unknown number, but not always, that's my point.)
>
> So I'm sorry, but I have to say I'm not convinced.
In my view, NA and NaN are two very different things. As you say, NaN*0
== NaN, by the definition of NaN. If you restrict the interpretation of NA
to "unknown numbwer (but still a number)", then NA*0==0 makes sense. Let
me give another example: suppose you have individuals whose income Y may be
missing, and their tax rate R (with no missing). Of course Y*R gives you
the amount due. If Y is NA, but R==0, why should you doubt that the amount
due is 0?
So I think that NA and NaN are fundamentally different, and should be
treated as such; note that we don't do this at present: if you try
series foo = ln(normal())
you get NAs rather NaNs. I accept that behaviour such as this should be
fixed, although not a priority IMO.
In R
xna <- NA # Not Available
xnan <- NaN
xpinf <- Inf
xminf <- -Inf
> 0*xna
[1] NA
> 0*xnan
[1] NaN
> 0*xpinf
[1] NaN
> 0*xminf
[1] NaN
I'm also not convinced.
On the basis of my reasoning above, I consider the first example above
wrong, with due respect to R (and octave).
Riccardo (Jack) Lucchetti
Dipartimento di Economia
Università Politecnica delle Marche
r.lucchetti(a)univpm.it
http://www.econ.univpm.it/lucchetti