[R] CI

Liaw, Andy andy_liaw at merck.com
Thu Oct 19 06:26:11 CEST 2006


You did ask for CI of mean, so that's what you got.  If you want CI for
proportion, here are two (non-bootstrap) ways:

R> confint(lm(I(x == 1) ~ 1), level=.9)
                  5 %      95 %
(Intercept) 0.2666456 0.6133544
R> binom.test(sum(x == 1), length(x), conf.level=.9)

        Exact binomial test

data:  sum(x == 1) and length(x) 
number of successes = 11, number of trials = 25, p-value = 0.69
alternative hypothesis: true probability of success is not equal to 0.5 
90 percent confidence interval:
 0.2698531 0.6213784 
sample estimates:
probability of success 
                  0.44 

I hope these are not HW problems?

Andy 

From: Ethan Johnsons 
> 
> Thank you so much for the feedback.
> 
> The random numbers are working great.  I have tried 
> non-random numbers, and the outcome is not correct with confint.
> 
> Is there a way to compute i.e. a 90% confidence interval for 
> percent of 1?
> 
> i.e. where 1 = apple; 2 = orange
> 
> > x
>  [1] 2 2 2 2 2 1 1 2 2 1 2 1 2 2 2 1 1 1 1 1 1 1 2 2 2
> > table (x)
> x
>  1  2
> 11 14
> 
> > x =11
> > confint(lm(x~1), level=0.90)
>             5 % 95 %
> (Intercept) NaN  NaN
> 
> ej
> 
> On 10/18/06, Liaw, Andy <andy_liaw at merck.com> wrote:
> > Here's one way:
> >
> > R> x <- c(6,11,5,14,30,11,17,3,9,3,8,8) confint(lm(x~1), level=.9)
> >                  5 %    95 %
> > (Intercept) 6.546834 14.2865
> >
> > Andy
> >
> > From: Ethan Johnsons
> > >
> > > I have a quick question, please.
> > >
> > > Does R have function to compute i.e. a 90% confidence 
> interval for 
> > > the mean for these numbers?
> > >
> > > > mean (6,11,5,14,30,11,17,3,9,3,8,8)
> > > [1] 6
> > >
> > > I thought pt or qt would give me the interval, but it seems not.
> > >
> > > thx much.
> > >
> > > ej
> > >
> > > ______________________________________________
> > > R-help at stat.math.ethz.ch 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.
> > >
> > >
> > >
> >
> >
> > 
> ----------------------------------------------------------------------
> > --------
> > Notice:  This e-mail message, together with any 
> attachments, contains 
> > information of Merck & Co., Inc. (One Merck Drive, 
> Whitehouse Station, 
> > New Jersey, USA 08889), and/or its affiliates (which may be known 
> > outside the United States as Merck Frosst, Merck Sharp & 
> Dohme or MSD 
> > and in Japan, as Banyu - direct contact information for 
> affiliates is 
> > available at http://www.merck.com/contact/contacts.html) 
> that may be 
> > confidential, proprietary copyrighted and/or legally 
> privileged. It is 
> > intended solely for the use of the individual or entity 
> named on this 
> > message. If you are not the intended recipient, and have 
> received this 
> > message in error, please notify us immediately by reply e-mail and 
> > then delete it from your system.
> >
> > 
> ----------------------------------------------------------------------
> > --------
> >
> 
> 
> 


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments,...{{dropped}}



More information about the R-help mailing list