Re: [R] CI using ci.numeric
On Oct 20, 2010, at 4:10 AM, David A. wrote: Hi, 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?? The next sentence suggests that what you are doing wrong is assuming that population parameters like the 0.75 and 0.25 quantiles (the IQR) are on the same scale as the confidence intervals around the population mean. As the number of samples increases the CI will narrow while the expected value of the IQR will remain the same. If you wanted to compare two values that remain on the same scale you ought to be looking at the SD rather than maen +/- 1.96*se(mean). The IQR goes from -0.62 to 0.62, so I thought the CI limits should be more extreme than these values. x<- rnorm(200,0,1) ci.numeric(x=mean(x),n=200,sds=sd(x),alpha=0.05) nmean sd se lower95ci upper95ci 1 200 -0.07129813 1.015668 0.07181859 -0.2129213 0.0703250 ci.numeric(x=mean(x),n=200,sds=sd(x),alpha=0.01) nmean sd se lower99ci upper99ci 200 -0.07129813 1.015668 0.07181859 -0.2580811 0.1154848 quantile(x) 0% 25% 50% 75%100% -3.23354673 -0.61926758 -0.06672757 0.62000897 2.43763696 Thanks, D. [[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. David Winsemius, MD West Hartford, CT __ 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.
Re: [R] CI using ci.numeric
2010/10/20 David A. > 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) # nmeansd 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.
[R] CI using ci.numeric
Hi, 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?? The IQR goes from -0.62 to 0.62, so I thought the CI limits should be more extreme than these values. x<- rnorm(200,0,1) ci.numeric(x=mean(x),n=200,sds=sd(x),alpha=0.05) nmean sd se lower95ci upper95ci 1 200 -0.07129813 1.015668 0.07181859 -0.2129213 0.0703250 ci.numeric(x=mean(x),n=200,sds=sd(x),alpha=0.01) nmean sd se lower99ci upper99ci 200 -0.07129813 1.015668 0.07181859 -0.2580811 0.1154848 quantile(x) 0% 25% 50% 75%100% -3.23354673 -0.61926758 -0.06672757 0.62000897 2.43763696 Thanks, D. [[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.