Learn R Programming

robsurvey (version 0.1.0)

weighted_quantile: Weighted lower sample quantiles

Description

weighted_quantile computes the weighted lower sample quantile

Usage

weighted_quantile(x, w, probs, na.rm = FALSE)

Arguments

x

a numeric vector whose weighted sample quantiles are wanted

w

a numeric vector of weights

probs

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

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

Value

Weighted sample quantiles

Details

Weighted lower quantiles are computed using an algorithm with \(O(n*log(n))\) in worst-case time. There exist superior algorithms; see Cormen et al. (2009, Problem 9.2).

References

Cormen,T.H., Leiserson, C.E., Rivest, R.L., and Stein, C. (2009): Introduction to Algorithms, 3rd ed., Cambridge: MIT Press.

See Also

weighted_median

Examples

Run this code
# NOT RUN {
x <- c(0.1, 0.35, 0.05, 0.1, 0.15, 0.05, 0.2)
weighted_quantile(x, x, probs = c(0.25, 0.5, 0.75))
# }

Run the code above in your browser using DataLab