wquant {pomp}R Documentation

Weighted quantile function

Description

Estimate weighted quantiles.

Usage

wquant(
  x,
  weights = rep(1, length(x)),
  probs = c(`0%` = 0, `25%` = 0.25, `50%` = 0.5, `75%` = 0.75, `100%` = 1)
)

Arguments

x

numeric; a vector of data.

weights

numeric; vector of weights.

probs

numeric; desired quantiles.

Details

wquant estimates quantiles of weighted data using the estimator of Harrell & Davis (1982), with improvements recommended by Andrey Akinshin (2023).

Value

wquant returns a vector containing the estimated quantiles. If probs has names, these are inherited.

Author(s)

Aaron A. King

References

F. E. Harrell and C. E. Davis. A new distribution-free quantile estimator. Biometrika 69, 635–640, 1982. doi:10.1093/biomet/69.3.635.

A. Akinshin. Weighted quantile estimators. arXiv:2304.07265, 2023. doi:10.48550/arxiv.2304.07265.

Examples

x <- c(1,1,1,2,2,3,3,3,3,4,5,5,6,6,6)
quantile(x)
wquant(x)
wquant(c(1,2,3,4,5,6),weights=c(3,2,4,1,2,3))
wquant(c(1,2,3,4,5),c(1,0,0,1,1))

[Package pomp version 5.11.0.0 Index]