Rounding [Software]
❝ SAS 9.2: round(125.005,0.01) → 125.01
❝ (Note the definition of rounding to 2 decimals as rounding to multiples of 0.01)
There is a similar function in Excel (has to be activated in Add-ins: Analysis Toolpak):
mround(125.005,0.01) → 125.01
But – like R:
Maxima: round(125.005*100)/100 → 125.00
❝ A more drastically example, may be important also in normal life I think:
❝ round(c(0.5,1.5,2.5,3.5,4.5,5.5),0)
❝ [1] 0 2 2 4 4 6
❝ At least in Germany one would expect:
❝ [1] 1 2 3 4 5 6
Splendid.
❝ Wow! Seems rounding the CI anyhow is not such a good idea.
Yes. Not so important for the conventional acceptance range, but we have double rounding for NTIDs (AR 90.00–111.11%). Must not forget to state
theta2=1.1111
in sampleN.TOST
explicitly.❝ [edit]Also the rounding seems to be implied by regulatory definitions of the acceptance range as 80.00 - 125.00 (EMA & FDA)![/edit]
<nitpick>
Well, the width of FDA's/EMA's AR is not 45% but 125.004–79.995=45.009%…
</nitpick>❝ But ... IMHO this must be independent from the used rounding method for 5 except the magnitude of deviation from the not rounded results since all the other results >125.0000 - 125.0049 will be also counted as BE if rounded and as not BE if not rounded.
Right. Maybe I will run a set and save individual results to a file. In the meantime I finished my balanced cross-over sim’s. n 12–60, CV 6–100%. With my grid I have 306·106 sim’s each. With rounding I got 24 (7.84%) empiric alphas significantly >0.05; without 11 (3.59%). If I take
power.TOST(CV=…, n=…, theta0=1.25)
as the gold standard and calculate the %RSE of the simulated alphas I see a positive bias of the rounding again: Q I median Q III
rounded -0.110 +0.218 +0.574
unrounded -0.404 -0.036 +0.325
Jiří showed me another gem. Try
sprintf("%.2f", round(125.005, 2))
sprintf("%.2f", 100*round(1.25005, 4))
Edit: 2012-01-05
After reading a lot of stuff on the net I guess the only way to get “commercial rounding” (the one we learned in school; 1–4 down, 5–9 up) in R without requiring a library is by a function (THX to an anonymous poster):
cround <- function(x,n){
z <- abs(x)*10^n
z <- z + 0.5
z <- trunc(z)
z <- z/10^n
z*sign(x)
}
round(c(79.994, 79.995, 125.004, 125.005), 2)
79.99 80.00 125.00 125.00
cround(c(79.994, 79.995, 125.004, 125.005), 2)
79.99 80.00 125.00 125.01
But note:
round(c(0.79994, 0.79995, 1.25004, 1.25005), 4)
0.7999 0.8000 1.2500 1.2501
cround(c(0.79994, 0.79995, 1.25004, 1.25005), 4)
0.7999 0.8000 1.2500 1.2501
Sometimes R drives me nuts.
Dif-tor heh smusma 🖖🏼 Довге життя Україна!
![[image]](https://static.bebac.at/pics/Blue_and_yellow_ribbon_UA.png)
Helmut Schütz
![[image]](https://static.bebac.at/img/CC by.png)
The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes
Complete thread:
- Rounding Helmut 2013-01-01 16:51 [Software]
- Rounding d_labes 2013-01-02 12:51
- RoundingHelmut 2013-01-04 17:35
- Rounding d_labes 2013-01-05 19:25
- Rounding Helmut 2013-01-05 20:13
- Sim’s are sim’s are sim’s d_labes 2013-01-05 20:57
- Another vicious circle Helmut 2013-01-06 02:21
- Where all these numbers came from? d_labes 2013-01-07 15:52
- Flaw in the GL? Helmut 2013-01-07 17:29
- Flaw in the GL? d_labes 2013-01-08 11:44
- What a mess! Helmut 2013-01-08 19:08
- What a mess! d_labes 2013-01-09 10:33
- What a mess! Helmut 2013-01-09 15:18
- What a mess! d_labes 2013-01-09 10:33
- What a mess! Helmut 2013-01-08 19:08
- Flaw in the GL? d_labes 2013-01-08 11:44
- Flaw in the GL? Helmut 2013-01-07 17:29
- Where all these numbers came from? d_labes 2013-01-07 15:52
- Rounding Helmut 2013-01-05 20:13
- Rounding d_labes 2013-01-05 19:25
- RoundingHelmut 2013-01-04 17:35
- Rounding ElMaestro 2013-01-02 16:12
- Abandon rounding Helmut 2013-01-02 17:04
- Rounding yjlee168 2013-01-05 23:15
- Rounding d_labes 2013-01-02 12:51