From rbaer at kcom.edu  Fri Apr 18 20:01:05 2003
From: rbaer at kcom.edu (rbaer@kcom.edu)
Date: Fri Apr 18 19:01:22 2003
Subject: [Rd] prop.test  confidence intervals (PR#2794)
Message-ID: <200304181701.h3IH15pD022324@pubhealth.ku.dk>

Full_Name: Robert W. Baer, Ph.D.
Version: 1.6.2
OS: Windows 2000
Submission from: (NULL) (198.209.172.106)


Problem:  prop.test() does not seem to produce appropriate confidence intervals
for the case where the vector length of x and n is one.  (I am not certain about
higher vector lengths.)

As an example, I include x=6 and n=42 which has a mean proportion of 0.115. 
When I calculate the 95% CI using the normal approximation by hand (and no
continuity correction) I get (0.028, 0.202).  The exact binomial CI from
binom.test() is (0.044, 0.234).  With correct=FALSE prop.test produces CI95 =
(0.05396969, 0.22971664) which is neither of these.  With correct=TRUE it
produces  (0.04778925, 0.2412937) This seems reasonably like a normal
approximation 95% CI (which I presume is what is used by prop.test()) of the
true binomial but I did not actually check it by hand.

BUG summary.  The prop.test() calculation of 95% CI of sample proportions is
improperly calculated when continuity correction is turned off.

-----------------------------
Sample R code and output shown below:


> x= 6;n=52
> prop.test(x,n,correct=TRUE)

        1-sample proportions test with continuity correction

data:  x out of n, null probability 0.5 
X-squared = 29.25, df = 1, p-value = 6.362e-08
alternative hypothesis: true p is not equal to 0.5 
95 percent confidence interval:
 0.04778925 0.24129372 
sample estimates:
        p 
0.1153846 

> prop.test(x,n,correct=FALSE)

        1-sample proportions test without continuity correction

data:  x out of n, null probability 0.5 
X-squared = 30.7692, df = 1, p-value = 2.906e-08
alternative hypothesis: true p is not equal to 0.5 
95 percent confidence interval:
 0.05396969 0.22971664 
sample estimates:
        p 
0.1153846 

> binom.test(x,n)

        Exact binomial test

data:  x and n 
number of successes = 6, number of trials = 52, p-value = 1.033e-08
alternative hypothesis: true probability of success is not equal to 0.5 
95 percent confidence interval:
 0.0435412 0.2344083 
sample estimates:
probability of success 
             0.1153846


[Rd] prop.test confidence intervals (PR#2794)
rbaer@kcom.edu