Learn R Programming

PSCBS (version 0.38.4)

weightedQuantile: Weighted Quantile Value

Description

Computes a weighted quantile of a numeric vector.

Usage

## S3 method for class 'default':
weightedQuantile(x, w, probs=c(0, 0.25, 0.5, 0.75, 1), na.rm=TRUE,
  method=c("wtd.quantile"), ...)

Arguments

x
a numeric vector containing the values whose weighted quantile is to be computed.
w
a numeric vector of weights the same length as x giving the weights to use for each element of x. Negative weights are treated as zero weights.
probs
a numeric vector of quantiles in [0,1] to be retrieved.
na.rm
a logical value indicating whether NA values in x should be stripped before the computation proceeds, or not.
method
If "wtd.quantile", then wtd.quantile of the Hmisc package is used. No other methods are currently supported.
...
Additional arguments passed to the estimator.

Value

  • Returns the weighted quantile.

See Also

Internally the following functions may be used: quantile (if no weights are specified), or wtd.quantile. For a weighted median estimator, weightedMedian of the matrixStats package.