Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: R: RE: Difference between codebook and count


From   "Carlo Lazzaro" <[email protected]>
To   <[email protected]>
Subject   st: R: RE: Difference between codebook and count
Date   Fri, 13 Jul 2007 12:10:44 +0200

Dear Maarten,

thanks a lot for Your (as usual) Kind and helpful hints.

In the meantime, I have performed an acid test on frequencies and values
with tabulate dosea1 and everything was OK (.2 included).

Thanks a lot again for Your Kindness and for Your time.

Cheers,

Carlo

-----Messaggio originale-----
Da: [email protected]
[mailto:[email protected]] Per conto di Maarten Buis
Inviato: venerd� 13 luglio 2007 11.54
A: [email protected]
Oggetto: st: RE: Difference between codebook and count

--- Carlo Lazzaro wrote:
>  I have experienced the following problem (please, see details below) with
.2
> value, which is reported with codebook but seemingly ignored with count.
> . codebook dosea1
>
----------------------------------------------------------------------------
> dosea1
> (unlabeled)
>
----------------------------------------------------------------------------
>                 type:  numeric (float)
>
>                 range:  [.2,1]                       units:  .1
<snip>
>
>. count if dosea1==.2
>    0

This is a due to the fact that computers and Stata count in base-2 and we
count
in base-10 numbers. The number .2 (base-10) cannot be held exactly in
base-2.
See the example below, and the possible solution using -round- in the -cond-

statement. 

*------------- begin example -------------------
scalar x = .2
di %23.18f  x
di "x " cond(x==.2,"is ", "is not ") ".2"
di "round(x,.1) " cond(round(x,.1)==.2,"is ", "is not ") ".2"
*--------------- end example --------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

For more on this issue see (Cox 2006) and (Gould 2006).

Hope this helps,
Maarten

N.J. Cox (2006), "Stata tip 33: Sweet sixteen: Hexadecimal 
formats and precision problems", The Stata Journal, 6(2), 
pp. 282-283.

W. Gould (2006), "Mata Matters: Precision", The Stata Journal, 6(4), 
pp. 550-560.

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology 
Vrije Universiteit Amsterdam 
Boelelaan 1081 
1081 HV Amsterdam 
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434 

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------



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


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