quantileCI {MKmisc} | R Documentation |
Confidence Intervals for Quantiles
Description
These functions can be used to compute confidence intervals for quantiles (including median).
Usage
quantileCI(x, prob = 0.5, conf.level = 0.95, method = "exact",
minLength = FALSE, na.rm = FALSE)
medianCI(x, conf.level = 0.95, method = "exact",
minLength = FALSE, na.rm = FALSE)
madCI(x, conf.level = 0.95, method = "exact", minLength = FALSE,
na.rm = FALSE, constant = 1.4826)
Arguments
x |
numeric data vector |
prob |
quantile |
conf.level |
confidence level |
method |
character string specifing which method to use; see details. |
minLength |
logical, see details |
na.rm |
logical, remove |
constant |
scale factor (see |
Details
The exact confidence interval (method = "exact"
) is computed using binomial
probabilities; see Section 6.8.1 in Sachs and Hedderich (2009). If the result is not
unique, i.e. there is more than one interval with coverage proability closest to
conf.level
, then a matrix of confidence intervals is returned.
If minLength = TRUE
, an exact confidence interval with minimum length is
returned.
The asymptotic confidence interval (method = "asymptotic"
) is based on the
normal approximation of the binomial distribution; see Section 6.8.1 in Sachs and Hedderich (2009).
Value
A list with components
estimate |
the sample quantile. |
CI |
a confidence interval for the sample quantile. |
Author(s)
Matthias Kohl Matthias.Kohl@stamats.de
References
L. Sachs and J. Hedderich (2009). Angewandte Statistik. Springer.
See Also
Examples
## To get a non-trivial exact confidence interval for the median
## one needs at least 6 observations
set.seed(123)
x <- rnorm(8)
## exact confidence interval not unique
medianCI(x)
madCI(x)
## minimum length exact confidence interval
medianCI(x, minLength = TRUE)
madCI(x, minLength = TRUE)
## asymptotic confidence interval
medianCI(x, method = "asymptotic")
madCI(x, method = "asymptotic")
## confidence interval for quantiles
quantileCI(x, prob = 0.4)
quantileCI(x, prob = 0.6)