View source: R/utils-helpers.R
| ci_quantile | R Documentation |
Computes a nonparametric confidence interval for a sample quantile using
the order-statistic method: the interval endpoints are order statistics
of x, chosen via the binomial distribution of ranks so that no assumption
is made about the shape of x's distribution.
ci_quantile(x, prob = 0.5, conf_level = 0.95)
x |
Numeric vector of observations |
prob |
Quantile probability (e.g. |
conf_level |
Confidence level |
Used by er_vpc_add_observed() to compute a confidence interval
for each requested percentile of the observed response within an
exposure bin (the observed-side analogue of the across-replicate
percentile interval er_vpc_add_simulated() gets from simulated data,
powering er_style_vpc_observed_quantile_errorbar()). Like
ci_clopper_pearson(), this interval is exact for its target coverage
but conservative – the discreteness of the binomial rank distribution
means the achieved coverage can exceed the nominal conf_level,
especially for a small bin or an extreme prob. The candidate rank
indices are clipped to [1, length(x)], so a very small or extreme-prob
bin returns a (still valid, but wider-than-nominal) interval built from
the most extreme order statistics available rather than NA.
Named numeric vector (lower, upper), with confidence level
stored as an attribute. Returns c(lower = NA, upper = NA) if fewer
than 2 non-missing values are supplied.
Conover, W. J. (1999). Practical Nonparametric Statistics (Third edition). New York: John Wiley & Sons. ISBN 0-471-16068-7.
ci_quantile(rnorm(100), prob = 0.1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.