[R] prop.test vs hand calculated confidence interval
Sarah Goslee
sarah.goslee at gmail.com
Thu Apr 4 00:17:56 CEST 2013
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
More information about the R-help
mailing list