[R] binom.test inside ctest

Kurt Hornik hornik at ci.tuwien.ac.at
Mon Sep 18 00:51:12 CEST 2000


>>>>> gb  writes:

> Bendix,

> that's what I meant. There are in fact _two_ border points, when you
> look at the two-sided test, 35 and 65. I thougt of taking half of each
> point, but expressed it in a sloppy way.

> The perhaps more interesting thing to discuss is whether this is a
> reasonable thing to do or not. Would the one-sided analogue to add
> half of the probability of the only border point to the p-value be
> equally reasonable? What do the experts say? References?

To start with, the result of binom.test(65, 100, p=0.5) which is
currently reported is not what is intended.  As Peter Dalgaard pointed
out, we need to add some fuzz to protect against differences of order
10^(-18) ...

There was some discussion on what the ``correct'' 2-sided p-value in the
discrete case is.  Some references simply use twice the smaller
one-sided probability.  I think the best approach is to use the prob
of ``observing a value at least as extreme as the one observed'', or
more precisely of ``observing a value no more likely than the one
observed''.  I.e., if X is the test statistic and d its probability
density function and x the value observed, then

	p-value = sum_{y: d(y) <= d(x)} d(y)

(see the comment

                            ## Do
                            ##   d <- dbinom(0 : n, n, p)
                            ##   sum(d[d <= dbinom(x, n, p)])
                            ## a bit more efficiently ...

in the code for binom.test().)

I don't have a reference available ... so if anyone else has ...

Simon Fear <fears at roycastle.liv.ac.uk> pointed me to an alternative
definition given in a paper by Vollset [sorry but I think I deleted the
exact reference] which

	defines an exact two-sided P value as

	  P = 2[f P(X=x) + min{P(X<x),P(X>x)}]

	where P() is evaluated under the null. This with f=.5 gives
	double the mid-P value, if f is one you get the definition in
	Cox and Snell. Either way, it is not the analogue of what we
	(and many others) have preferred for the Fisher's test.

I have been wanting for some time to take a closer look into this, and
maybe implement the above for the discrete tests in ctest.  No time thus
far ... if someone else wants to give this a shot, pls feel free.

-k

> Göran

> On Tue, 12 Sep 2000, BXC (Bendix Carstensen) wrote:

>> 
>> > -----Original Message-----
>> > From: gb [mailto:gb at stat.umu.se]
>> > Sent: 12. september 2000 08:40
>> > To: Mai Zhou
>> > Cc: r-help at stat.math.ethz.ch
>> > Subject: Re: [R] binom.test inside ctest
>> > 
>> > 
>> > Mai,
>> > 
>> > it seems as if binom.test only adds half the probability of
>> > of the border point 65 to the p-value. If you try
>> > 
>> > > (1-pbinom(64, 100, p = 0.5)) + pbinom(34, 100, p=0.5)
>> > [1] 0.002653786
>> > 
>> > you get the same result as binom.test.
>> 
>> Göran,
>> 
>> Rather, it adds the border point only once:
>> I think the general idea is:
>> 
>> > db <- dbinom(0:100,100,p=0.5)
>> > obs.p <- dbinom(65,100,p=0.5)
>> > sum(db[db<obs.p])+obs.p
>> [1] 0.002653786
>> 
>> Bendix 
>> > 
>> > 
>> > Göran
>> > 
>> > On Tue, 12 Sep 2000, Mai Zhou wrote:
>> > 
>> > > I got 
>> > > 
>> > > binom.test(65, 100, p=0.5)
>> > > 
>> > > 
>> > > p-value = 0.002654
>> > > 
>> > > I thought in this case (when p=0.5 so a symmetric distribution)
>> > > we should get 
>> > > 
>> > > p-value = 2*( 1-pbinom(64, 100, p=0.5) ) = 0.003517642
>> > > 
>> > > Can somebody explain why the difference?
>> > > 
>> > > Thanks.
>> > > 
>> > > Mai Zhou
>> > > 
>> > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
>> > -.-.-.-.-.-.-.-.-
>> > > 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
>> > > 
>> > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
>> > _._._._._._._._._
>> > > 
>> > 
>> > -- 
>> >  Göran Broström                      tel: +46 90 786 5223
>> >  Department of Statistics            fax: +46 90 786 6614
>> >  Umeå University
>> >  SE-90187 Umeå, Sweden             e-mail: gb at stat.umu.se
>> > 
>> 
>> ----------------------
>> Bendix Carstensen
>> Senior Statistician
>> Steno Diabetes Centre
>> Niels Steensens Vej 2
>> DK-2820 Gentofte
>> Denmark
>> tel: +45 44 43 87 38
>> mob: +45 28 25 87 38
>> fax: +45 44 43 73 13
>> bxc at novo.dk
>> www.biostat.ku.dk/~bxc
>> ----------------------
>> 
>> 

> -- 
>  Göran Broström, professor           tel: +46 90 786 5223
>  Department of Statistics            fax: +46 90 786 6614
>  Umeå University
>  SE-90187 Umeå, Sweden             e-mail: gb at stat.umu.se

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

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