[R] binom.test and small N

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Fri Mar 22 23:45:05 CET 2002


Tony Long <tdlong at uci.edu> writes:

> running R 1.4.1 on MAC and 1.2.2 on Linux
> 
> When I use run binom.test with small N the results are a little
> perplexing to me
> 
> >binom.test(9,20,p=0.5)
> 
> gives the below plus other stuff
> 
> 95 percent confidence interval:
>   0.2305779 0.6847219
> 
> Now:
> 
> >pbiom(9,20,0.6847219)
> [1] 0.02499998    # i.e., lower 2.5% of distribution
> >pbinom(9,20,0.2305779)
> [1] 0.9923132
> >pbinom(8,20,0.2305779)
>   [1] 0.975     # i.e.,  upper 2.5% of distribution
> 
> I would think I generally want a 95% CI on the observed 9 out of 20,
> not 8 out of 20 LB and 9 out of 20 UB.  I am missing something or is
> this strictly a function of the beta approximation used in the source
> code??

The devil is lurking in de tails...

Notice that you want "this or worse" in both cases, i.e. solve

P(X <= 9) = 2.5% for the upper bound and
P(X >= 9) = 2.5% for the lower bound

now, P(X >= 9) = 1 - P(X <= 8) for integer X.
-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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