Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Mata Behaviour for Missing Data and Op. Logic
From 
 
Marta García-Granero <[email protected]> 
To 
 
[email protected] 
Subject 
 
Re: st: Mata Behaviour for Missing Data and Op. Logic 
Date 
 
Tue, 11 Jun 2013 12:54:49 +0200 
Hi Matthew
El 11/06/2013 11:53, Matthew McKay escribió:
Dear StataList,
I am debugging some MATA code that I have written and I have come across an issue:
I am iterating over a list of values: [0 0.2 0.1 .... Etc] and comparing each element with some cutoff level (ie 0.2).
I am finding that if there are any missing items in the original list: [0   0.1   .    0.2    0.3];
Then items that are missing evaluate to TRUE when greater than the cutoff.
(. > 0.2) -> 1
And evaluates to false when less than the cutoff
(. < 0.2) -> 0
I had assumed that if data was 'missing' it would either return 'missing' or return FALSE in both comparison cases!
Can anyone explain this to me?
(i.e. is missing (.) considered to be infinitely large?)
Yes, that's exactly what happens. From the help for missing:
Description
    Stata has 27 numeric missing values:
        ., the default, which is called the "system missing value" or 
sysmiss
    and
        .a, .b, .c, ..., .z, which are called the "extended missing 
values".
    Numeric missing values are represented by large positive values.  
The ordering is
                                                      all nonmissing 
numbers < . < .a < .b < ... < .z
    Thus, the expression age > 60 is true if variable age is greater 
than 60 or missing.
    To exclude missing values, ask whether the value is less than ".".  
For instance,
        . list if age > 60 & age < .
    To specify missing values, ask whether the value is greater than or 
equal to ".".  For instance,
        . list if age >=.
HTH,
Marta GG
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/