QuantileCI {DescTools} | R Documentation |
Confidence Interval for Any Quantile
Description
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.
Usage
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)
Arguments
x |
a (non-empty) numeric vector of data values. |
probs |
numeric vector of probabilities with values in [0,1]. (Values up to |
conf.level |
confidence level of the interval |
sides |
a character string specifying the side of the confidence interval, must be one of |
na.rm |
logical. Should missing values be removed? Defaults to |
method |
defining the type of interval that should be calculated (one out of |
R |
The number of bootstrap replicates. Usually this will be a single positive integer. See
|
Details
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"
.
Value
if probs was of length 1 a numeric vector with 3 elements:
est |
est |
lwr.ci |
lower bound of the confidence interval |
upr.ci |
upper bound of the confidence interval |
or, if probs was a vector, a matrix with 3 columns consisting of estimate, lower ci, upper ci
est, lwr.ci, upr.ci
Author(s)
Andri Signorell <andri@signorell.net> based on code of W Huber on StackExchange
See Also
Examples
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)
# multiple probs
QuantileCI(1:100, method="exact" , probs = c(0.25, 0.75, .80, 0.95))
QuantileCI(1:100, method="boot" , probs = c(0.25, 0.75, .80, 0.95))