[R] binom.test()

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Mon Sep 23 12:37:43 CEST 2002


Thomas Lumley <tlumley at u.washington.edu> writes:

> 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?
> >
> 
> Actually the previous explanation is completely bogus (I plead jet lag).
> The problem is in handling 2-tailed p-values, which is done by looking for
> the value in the opposite tail where the density is <= (1+1e-7) times the
> observed density.  The problem is that the observed density is 0.
> 
> It should be possible just to change <= to <, possibly increasing the
> fudge factor from 1e-7 but perhaps not.

That would create different problems, I suspect. The main issue seems
to be that this construct

                i <- seq(from = 0, to = x - 1)
                y <- sum(dbinom(i, n, p) <= d * relErr)
                pbinom(y - 1, n, p) + pbinom(x - 1, n, p, lower = FALSE)

is assumed to give y somewhere in the left tail, but in this case we
count some values in the right (i.e. wrong...) tail too. I'd expect
that using something like 

                i <- seq(from = 0, to = ceiling(n*p))

might work, but don't take my word for it...


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