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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 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 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
At 00:22 12/09/00 -0400, you 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 ZhouHi, When looking in the R code (in RHOME/library/ctest/R/ctest), you can see that the p-value is computed like this:> ( 1-pbinom(64, 100, p=0.5) ) + pbinom(34, 100, p=0.5)[1] 0.002653786 The relevant bit of code is: ## Do ## d <- dbinom(0 : n, n, p) ## sum(d[d <= dbinom(x, n, p)]) ## a bit more efficiently ... d <- dbinom(x, n, p) if(x / n < p) { i <- seq(from = x + 1, to = n) y <- sum(dbinom(i, n, p) <= d) pbinom(x, n, p) + (1 - pbinom(n - y, n, p)) } else { i <- seq(from = 0, to = x - 1) y <- sum(dbinom(i, n, p) <= d) pbinom(y - 1, n, p) + (1 - pbinom(x - 1, n, p)) } Emmanuel Paradis -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> -----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 ---------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._