Re: [R] proportions confidence intervals

From: Spencer Graves <spencer.graves_at_pdf.com>
Date: Tue 13 Jul 2004 - 03:44:25 EST

      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

      hope this helps. spencer graves

Darren Shaw wrote:

> Dear R users
>
> this may be a simple question - but i would appreciate any thoughts
>
> does anyone know how you would get one lower and one upper confidence
> interval for a set of data that consists of proportions. i.e. taking
> a usual confidence interval for normal data would result in the lower
> confidence interval being negative - which is not possible given the
> data (which is constrained between 0 and 1)
>
> i can see how you calculate a upper and lower confidence interval for
> a single proportion, but not for a set of proportions
>
> many thanks
>
>
> Darren Shaw
>
>
>
> -----------------------------------------------------------------
> Dr Darren J Shaw
> Centre for Tropical Veterinary Medicine (CTVM)
> The University of Edinburgh
> Scotland, EH25 9RG, UK
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jul 13 04:12:43 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 02:35:42 EST