Confidence intervals of quantiles
Many thanks for all the contributions to this problem. As inferred by Ted Harding, I was after a distribution-free CIs as a lot of the data I use is not normally distributed. The method provided by Ted for calculating exact CIs gave good results with the limits almost symmetric about the quantile. Even for my smaller data set with only 115 samples and a very skewed distribution the results clearly showed the increase in range and asymmetry of the confidence limits. The bootstrap method provided by Dimitris also works reasonably well but is slower and the ranges for the CIs are sometimes very asymmetric and in one case did not actually encompass the quantile. The method would not work at all with the skewed distribution of 115 samples until I reduced the quantile range from 0.1 and 0.9 to 0.2 and 0.8 However, as Dimitris warned, you have to be careful with this method for extreme quantiles and small samples. I was also sent a method by S?ren Merser, but this was incomplete. This method was written by Scott Chasalow and the full code can be found at http://www.dpw.wau.nl/pv/pub/chasalow/S/win/ci.quantile/ The code was written for S-Plus but it worked ok for me in R. This method actually gives several ranges about the quantile, each with about the same level of confidence and the level of confidence is also in the output. As with Ted Harding's method, these may not exactly match the desired confidence level. There is an option to select the shortest range but it would be easy enough to add code to give the most symmetric range. As a chemist I am not able to comment on the statistical pros and cons of the methods but they are certainly very helpful for my purposes. Many thanks Mike White ----- Original Message ----- From: "Dimitris Rizopoulos" <dimitris.rizopoulos at med.kuleuven.be> To: "Mike White" <mikewhite.diu at btconnect.com> Cc: <R-help at stat.math.ethz.ch> Sent: Monday, February 05, 2007 2:43 PM Subject: Re: [R] Confidence intervals of quantiles
you could use the Bootstrap method, using package 'boot', e.g.,
library(boot)
f.quantile <- function(x, ind, ...){
quantile(x[ind], ...)
}
###########
x <- rgamma(750, 2)
quant.boot <- boot(x, f.quantile, R = 1000, probs = c(0.025, 0.25,
0.5, 0.75, 0.975))
lapply(1:5, function(i) boot.ci(quant.boot, c(0.90, 0.95), type =
c("perc", "bca"), index = i))
y <- rgamma(150, 2)
quant.boot <- boot(y, f.quantile, R = 1000, probs = c(0.025, 0.25,
0.5, 0.75, 0.975))
lapply(1:5, function(i) boot.ci(quant.boot, c(0.90, 0.95), type =
c("perc", "bca"), index = i))
However, you should be a little bit careful with Bootstrap if you wish
to obtain CIs for extreme quantiles in small samples.
I hope it helps.
Best,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
----- Original Message -----
From: "Mike White" <mikewhite.diu at btconnect.com>
To: <R-help at stat.math.ethz.ch>
Sent: Monday, February 05, 2007 2:47 PM
Subject: [R] Confidence intervals of quantiles
Can anyone please tell me if there is a function to calculate confidence intervals for the results of the quantile function. Some of my data is normally distributed but some is also a squewed distribution or a capped normal distribution. Some of the data sets contain about 700 values whereas others are smaller with about 100-150 values, so I would like to see how the confidence intervals change for the different distributions and different data sizes. Thanks Mike White
______________________________________________ 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.
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
___________________________________________________________ Tiscali Broadband only 9.99 a month for your first 3 months! http://www.tiscali.co.uk/products/broadband/