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

RE: st: help on round function


From   n j cox <[email protected]>
To   [email protected]
Subject   RE: st: help on round function
Date   Tue, 13 Dec 2005 09:40:03 +0000

Hmm. Well, this is an old idea. The logic, as I understand it,
is best explained by this argument:

0 as a last digit needs no rounding.
1 to 4 clearly we should round down.
6 to 9 round up.

If we decide to round 5 up, and assume a uniform distribution
of last digits, then we would round up 5/10 times, round down
4/10 times and so create a net bias.

Rounding 5 down would create a net bias the other way.

So the solution is to round up half the time and
round down half the time and doing it on preceding
odd and even digits is one way to toss that coin
systematically.

BUT

0. This is at best arbitrary, unless I'm missing
something. What if someone decides the opposite rule is
more tasteful?

1. It is more complicated than you might want.
I can never remember which way round [sic] it is.

2. My impression is that no software does this
for you. At least, I don't recall ever seeing this
documented in any manual.

3. This seems all predicated on the idea that the
ultimate sin is to be biased in estimating a mean.
But getting the last digit wrong doesn't worry any
sane analyst. Or, don't round so much!

As for Clive's question, I think you'd have to
do the maninpulations on the -string()-ed version.
But you might have to fight Stata's own rounding rules.

Nick
[email protected]

Notice that the Pagano here is not our Marcello.
Perhaps a fifth cousin?

>>> Clive Nicholas

Svend Juul replied to Fred Wolfe:

> Fred gave some good explanations. The problem is that 8.765 is as close
> to 8.76 as to 8.77, so both results are equally valid. If you for some
> reason feel that this result MUST be rounded up, you can:
>    gen y=round(x+0.00001, 0.01).

At this stage, Stata has done its job and it falls to the user to make a
judgement. One way of making a good and informed judgement is to use
rounding rules. A good summary of such rules is provided by Pagano (1994:
29-30). In particular, he argues that where the decimal remainder is dead
on .5, the greater part is only rounded up if the last digit before the
decimal remainder is an odd number. In the above example, we have 8.765,
so if we're rounding up to two decimal points, we leave it at 8.76. If it
was 8.775, we would, of course, have rounded up to 8.78. It would be
interesting to know of ways whereby one could 'fix' Stata to use this rule
permanently.

Pagano RR (4th ed, 1994) UNDERSTANDING STATISTICS IN THE BEHAVORIAL
SCIENCES, St Paul, MN: West.

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