Liaw, Andy wrote: > Here's one way: > > R> x <- c(6,11,5,14,30,11,17,3,9,3,8,8) > R> confint(lm(x~1), level=.9) > 5 % 95 % > (Intercept) 6.546834 14.2865 > > Andy
Or without assuming normality, library(Hmisc) smean.cl.boot(x, conf.int=.9, B=10000) Mean Lower Upper 10.416667 7.333333 14.083333 This took 0.33 seconds using code that is optimized for bootstrapping the mean to get percentile confidence intervals. The lack of symmetry in the bootstrap CL correctly reflects the asymmetry in the data. Or: library(boot) w <- boot(x, function(a,b)mean(a[b]), R=10000) # took 1 sec. boot.ci(w, conf=.9) # 2.6 sec. BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS Based on 10000 bootstrap replicates CALL : boot.ci(boot.out = w, conf = 0.9) Intervals : Level Normal Basic 90% ( 6.99, 13.79 ) ( 6.75, 13.50 ) Level Percentile BCa 90% ( 7.33, 14.08 ) ( 7.67, 14.92 ) Calculations and Intervals on Original Scale I choose 10000 reps to get virtually the same CI on multiple runs. Frank > > 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 -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University ______________________________________________ R-help@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.