Re: [R] two-tailed exact binomail test

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Sat 27 Aug 2005 - 23:12:05 EST

katrina smith <chezsmithy@yahoo.co.uk> writes:

> I am trying to find a definition for the two-tailed exact binomial
> test but have been unsuccessful. Can you help?

Just read binom.test. The relevant bit is this: (m is the mean == n*p)

            else if (x < m) {
                i <- seq(from = ceiling(m), to = n)
                y <- sum(dbinom(i, n, p) <= d * relErr)
                pbinom(x, n, p) + pbinom(n - y, n, p, lower = FALSE)
            }

i.e. we take the lower tail, including the value observed + the part of the upper tail where the binomial density is less than or equal to that of x (with a little fuzz added in). Symmetrically for observations in the upper tail of course.

If you were looking for an "official" definition of the two sided exact test, I don't think one exists. R's version is equivalent to the likelihood ratio test, but there are alternatives (tail-balancing, doubling the one-sided p, and maybe more).

-- 
   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sat Aug 27 23:29:33 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:57 EST