[R] proportions confidence intervals

Chuck Cleland ccleland at optonline.net
Mon Jul 12 20:19:16 CEST 2004


   Darren also might consider binconf() in library(Hmisc).

 > library(Hmisc)

 > binconf(1, 10, method="all")
            PointEst        Lower     Upper
Exact           0.1  0.002528579 0.4450161
Wilson          0.1  0.005129329 0.4041500
Asymptotic      0.1 -0.085938510 0.2859385

 > binconf(10, 100, method="all")
            PointEst      Lower     Upper
Exact           0.1 0.04900469 0.1762226
Wilson          0.1 0.05522914 0.1743657
Asymptotic      0.1 0.04120108 0.1587989

Spencer Graves wrote:
>      Please see:
>      Brown, Cai and DasGupta (2001) Statistical Science, 16:  101-133 
> and (2002) Annals of Statistics, 30:  160-2001
>      They show that the actual coverage probability of the standard 
> approximate confidence intervals for a binomial proportion are quite 
> poor, while the standard asymptotic theory applied to logits produces 
> rather better answers.
>      I would expect "confint.glm" in library(MASS) to give decent 
> results, possibly the best available without a very careful study of 
> this particular question.  Consider the following:
>  library(MASS)# needed for confint.glm
>  library(boot)# needed for inv.logit
>  DF10 <- data.frame(y=.1, size=10)
>  DF100 <- data.frame(y=.1, size=100)
>  fit10 <- glm(y~1, family=binomial, data=DF10, weights=size)
>  fit100 <- glm(y~1, family=binomial, data=DF100, weights=size)
>  inv.logit(coef(fit10))
> 
>  (CI10 <- confint(fit10))
>  (CI100 <- confint(fit100))
> 
>  inv.logit(CI10)
>  inv.logit(CI100)
> 
>      In R 1.9.1, Windows 2000, I got the following:
> 
>>   inv.logit(coef(fit10))
> 
> (Intercept)
>        0.1
> 
>>  
>>   (CI10 <- confint(fit10))
> 
> Waiting for profiling to be done...
>     2.5 %     97.5 %
> -5.1122123 -0.5258854
> 
>>   (CI100 <- confint(fit100))
> 
> Waiting for profiling to be done...
>    2.5 %    97.5 %
> -2.915193 -1.594401
> 
>>  
>>   inv.logit(CI10)
> 
>      2.5 %      97.5 %
> 0.005986688 0.371477058
> 
>>   inv.logit(CI100)
> 
>    2.5 %    97.5 %
> 0.0514076 0.1687655
> 
>>
>>   (naiveCI10 <- .1+c(-2, 2)*sqrt(.1*.9/10))
> 
> [1] -0.08973666  0.28973666
> 
>>   (naiveCI100 <- .1+c(-2, 2)*sqrt(.1*.9/100))
> 
> [1] 0.04 0.16

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894




More information about the R-help mailing list