[R] binom.test()
Thomas Lumley
tlumley at u.washington.edu
Mon Sep 23 04:31:42 CEST 2002
On Mon, 23 Sep 2002, Robin Hankin wrote:
> Hello everybody.
>
> Does anyone else find the last test in the following sequence odd?
> Can anyone else reproduce it or is it just me?
>
>
> > binom.test(100,200,0.13)$p.value
> [1] 2.357325e-36
> > binom.test(100,200,0.013)$p.value
> [1] 6.146546e-131
> > binom.test(100,200,0.0013)$p.value
> [1] 1.973702e-230
> > binom.test(100,200,0.00013)$p.value
> [1] 0.9743334
>
Yes. The p-value is evaluated by adding up binomial probabilities, but it
leads to catastrophic rounding error.
One solution would be to use the incomplete beta function (pbeta) either
always or in extreme cases. That's how the confidence limits are computed
and they don't break down in this case.
So eg
> pbeta(0.13,100,101)
[1] 2.357325e-36
> pbeta(0.013, 100, 101)
[1] 6.146546e-131
> pbeta(0.0013,100,101)
[1] 1.973702e-230
> pbeta(0.00013, 100, 101)
[1] 0
which agrees on the first three and is a lot closer on the last.
-thomas
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list