weighted_quantile {reservr}R Documentation

Compute weighted quantiles

Description

Compute weighted quantiles

Usage

weighted_quantile(x, w, probs)

weighted_median(x, w)

Arguments

x

Observations

w

Case weights (optional)

probs

Quantiles to calculate

Value

A vector the same length as probs with the corresponding weighted quantiles of x with weight w. For integer weights, this is equivalent to quantile(rep(x, w), probs)

The weighted median of x with weights w. For integer weights, this is equivalent to median(rep(x, w))

See Also

Other weighted statistics: weighted_moments(), weighted_tabulate()

Examples

weighted_median(1:6)
weighted_median(1:3, c(1, 4, 9))
weighted_median(1:3, c(9, 4, 1))

weighted_quantile(1:3, c(1, 4, 9), seq(0.0, 1.0, by = 0.25))
quantile(rep(1:3, c(1, 4, 9)), seq(0.0, 1.0, by = 0.25))

[Package reservr version 0.0.3 Index]