Skip to content
Prev 7236 / 398498 Next

binom.test inside ctest

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