Compute the sample size necessary to achieve a specified confidence level for a nonparametric confidence interval for a quantile.
Arguments
- p
numeric vector of probabilities specifying the quantiles. All values of
pmust be between 0 and 1. The default value isp=0.5.- lcl.rank, n.plus.one.minus.ucl.rank
numeric vectors of non-negative integers indicating the ranks of the order statistics that are used for the lower and upper bounds of the confidence interval for the specified quantile(s). When
lcl.rank=1that means use the smallest value as the lower bound, whenlcl.rank=2that means use the second to smallest value as the lower bound, etc. Whenn.plus.one.minus.ucl.rank=1that means use the largest value as the upper bound, whenn.plus.one.minus.ucl.rank=2that means use the second to largest value as the upper bound, etc. A value of0forlcl.rankindicates no lower bound (i.e., -Inf) and a value of0forn.plus.one.minus.ucl.rankindicates no upper bound (i.e.,Inf). Whenci.type="upper"thenlcl.rankis set to0by default, otherwise it is set to1by default. Whenci.type="lower"thenn.plus.one.minus.ucl.rankis set to0by default, otherwise it is set to1by default.- ci.type
character string indicating what kind of confidence interval to compute. The possible values are
"two-sided"(the default),"lower", and"upper".- conf.level
numeric vector of numbers between 0 and 1 indicating the confidence level associated with the confidence interval(s). The default value is
conf=0.95.
Details
If the arguments p, lcl.rank,
n.plus.one.minus.ucl.rank and conf.level are not all the
same length, they are replicated to be the
same length as the length of the longest argument.
The help file for eqnpar explains how nonparametric confidence
intervals for quantiles are constructed and how the confidence level
associated with the confidence interval is computed based on specified values
for the sample size and the ranks of the order statistics used for
the bounds of the confidence interval.
The function ciNparN determines the required the sample size via
a nonlinear optimization.
References
See the help file for eqnpar.
Author
Steven P. Millard (EnvStats@ProbStatInfo.com)
Note
See the help file for eqnpar.
Examples
# Look at how the required sample size for a confidence interval
# increases with increasing confidence level for a fixed quantile:
seq(0.5, 0.9, by = 0.1)
#> [1] 0.5 0.6 0.7 0.8 0.9
#[1] 0.5 0.6 0.7 0.8 0.9
ciNparN(p = 0.9, conf.level=seq(0.5, 0.9, by = 0.1))
#> [1] 7 9 12 16 22
#[1] 7 9 12 16 22
#----------
# Look at how the required sample size for a confidence interval increases
# as the quantile moves away from 0.5:
ciNparN(p = seq(0.5, 0.9, by = 0.1))
#> [1] 6 7 9 14 29
#[1] 6 7 9 14 29