qexact: Exact Confidence Intervals for Quantiles

View source: R/Qtools.R

qexactR Documentation

Exact Confidence Intervals for Quantiles

Description

Compute exact confidence intervals for quantiles of continuous random variables using binomial probabilities

Usage

qexact(x, probs = 0.5, level = 0.95)

Arguments

x

numeric vector whose sample quantile and confidence intervals are to be calculated.

probs

numeric vector of probabilities with values in [0,1].

level

nominal coverage level of the confidence interval.

Details

This function calculates exact confidence intervals for quantiles at level probs from a vector x of length n. It does so by first determining the confidence level for all possible pairwise combinations of order statistics from 1 to n. This entails "n choose 2" possible confidence intervals before selecting the one with the level closest to level. If the procedure yields more than one such confidence intervals, then the interval with smallest width is returned.

Caution: for large n, the procedure may reach the limit on the number of nested expressions. See gtools::combinations and options(expressions) for additional information. However, if you have a large n, then consider estimating an asymptotic approximation of the confidence interval.

Author(s)

Marco Geraci

References

Thompson W. R. On confidence ranges for the median and other expectation distributions for populations of unknown distribution form. The Annals of Mathematical Statistics 1936;7(3):122-128.

Examples

x <- rnorm(100)
qexact(x, p = c(0.1,0.5), level = 0.9)

Qtools documentation built on Nov. 2, 2023, 6:11 p.m.