2010/10/20 David A. <dasol...@hotmail.com> > I am trying to calculate confidence intervals using ci.numeric from > epicalc package. If I generate a normal set of data and find the 99% and 95% > CI, they seem too narrow to me. Am I doing something wrong??
Yes. set.seed(123) x<- rnorm(200,0,1) ci.numeric(x=mean(x),n=length(x),sds=sd(x),alpha=0.05) # n mean sd se lower95ci upper95ci # 200 -0.008570445 0.9431599 0.06669147 -0.1400831 0.1229422 # Let's compute lower CI of a mean usnig t-distribution as it is in ci.numeric mean(x) - qt(p = (1 - .05/2),df=length(x)-1) * sd(x)/sqrt(length(x)) # [1] -0.1400831 # now using normal distribution mean(x) - qnorm(p = (1 - .05/2)) * sd(x)/sqrt(length(x)) # [1] -0.1392833 -- Mi³ego dnia [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org 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.