Calculates the confidence interval for any quantile. Although bootstrapping might be a good approach for getting senisble confidence intervals there's sometimes need to have a nonparameteric alternative. This function offers one.
QuantileCI(x, probs=seq(0, 1, .25), conf.level = 0.95,
sides = c("two.sided", "left", "right"),
na.rm = FALSE, method = c("exact", "boot"), R = 999)
a (non-empty) numeric vector of data values.
numeric vector of probabilities with values in [0,1]. (Values up to 2e-14
outside that range are accepted and moved to the nearby endpoint.)
confidence level of the interval
a character string specifying the side of the confidence interval, must be one of "two.sided"
(default), "left"
or "right"
(abbreviations allowed). "left"
would be analogue to a "greater"
hypothesis in a t.test
.
logical. Should missing values be removed? Defaults to FALSE
.
defining the type of interval that should be calculated (one out of "exact"
, "boot"
). Default is "exact"
. See Details.
The number of bootstrap replicates. Usually this will be a single positive integer. See
boot.ci
for details.
if probs was of length 1 a numeric vector with 3 elements:
est
lower bound of the confidence interval
upper bound of the confidence interval
%% ~Describe the value returned %% If it is a LIST, use %% \item{comp1 }{Description of 'comp1'} %% \item{comp2 }{Description of 'comp2'} %% ...
The "exact"
method corresponds to the way the confidence interval for the median is calculated in SAS.
The boot confidence interval type is calculated by means of boot.ci
with default type "basic"
.
# NOT RUN {
QuantileCI(d.pizza$price, probs=0.25, na.rm=TRUE)
QuantileCI(d.pizza$price, na.rm=TRUE)
QuantileCI(d.pizza$price, conf.level=0.99, na.rm=TRUE)
# }
Run the code above in your browser using DataLab