[R] prop.test vs hand calculated confidence interval

Albyn Jones jones at reed.edu
Thu Apr 4 00:52:06 CEST 2013


It might help to look at the documentation.
Typing 

   ?prop.test

on the command line.  That would reveal various items of
interest, including a section labeled "Details".  A close
reading of that section turns up the explanation:

  "The confidence interval is computed by inverting the score test."

There are also journal references given.

albyn

On Wed, Apr 03, 2013 at 06:17:56PM -0400, Sarah Goslee wrote:
> One of the joys of R is that it's open source: you can read the code
> for prop.test yourself and see what's happening.
> 
> In this case, simply typing
> prop.test
> at the command line will provide it, although without comments.
> 
> Sarah
> 
> 
> 
> On Wed, Apr 3, 2013 at 6:10 PM, David Arnold <dwarnold45 at suddenlink.net> wrote:
> > Hi,
> >
> > This code:
> >
> > n=40
> > x=17
> > phat=x/n
> > SE=sqrt(phat*(1-phat)/n)
> > zstar=qnorm(0.995)
> > E=zstar*SE
> > phat+c(-E,E)
> >
> > Gives this result:
> >
> > [1] 0.2236668 0.6263332
> >
> > The TI Graphing calculator gives the same result.
> >
> > Whereas this test:
> >
> > prop.test(x,n,conf.level=0.99,correct=FALSE)
> >
> > Give this result:
> >
> > 0.2489036 0.6224374
> >
> > I'm wondering why there is a difference.
> >
> > D.
> >
> >
> 
> --
> Sarah Goslee
> http://www.functionaldiversity.org
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

-- 
Albyn Jones
Reed College
jones at reed.edu



More information about the R-help mailing list