[R] small bug in binom.test?
ripley@stats.ox.ac.uk
ripley at stats.ox.ac.uk
Wed Jan 22 10:25:04 CET 2003
On Wed, 22 Jan 2003, Jerome Goudet wrote:
> At 22.01.2003 08:45 +0000, you wrote:
> >Why do you think that?
> >
> >The problems binom.test(49,50,0.5) and binom.test(51,100,0.5) are
> >symmetrical, so one would expect the same results for a two-sided test.
> >
> >The problem I guess is how a two-sided test is defined for a discrete
> >distribution. For one-sided tests one would use the probability of X >=11
> >or X <= 9, and those are not equal. For a two-sided test the code
> >attempts to find a point in the opposite tail with at least as large a
> >tail probability, and adds on that tail probability. Thus for
> >binom.test(11,100,p=0.1) it used P(X < 9 || X >= 11), and for
> >binom.test(9,100,p=0.1) it used P(X <= 9 || X > 10), if I followed the
> >code right.
(I typed it wrong. The first omits (9,10), the second (10,11).)
> I would have defined the two sided test as P(X<=9 || X>=11) (checking of
> course that if the two values are equal, the probability is not counted
> twice). Is this wrong?
Yes. Let me repeat: `why do you think that?'. (R implements standard
statistical definitions, not Goudet's ones, so I expected you to give me a
reference.) Did you look up the references on the help page?
For continuous distributions, two-tailed tests are defined as equi-tailed,
and so your recipe is nothing like what happens for e.g. a gamma
distribution. For discrete distributions there are complications but
there is a standard definition of an alpha-level test, which can be
converted to a p value via searching for possible alpha-level tests.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list