Calculates the weighted median of a vector x with its corresponding w.
Usage
wmedian(x, w, a=0.5)
Value
a numeric value.
Arguments
x
a numeric vector of observations.
w
a numeric vector of weights corresponding to x.
a
the offset fraction in [0,1].
A value of zero calculates the left quantile of the weighted empirical cumulative distribution function (CDF),
while a value of one calculates the right quantile of the weighted empirical CDF.
Author
Chanseok Park
Details
The weighted empirical CDF is defined by
$$
F_w(t) = \sum_{j=1}^{n} w_j I(x_j \le t),$$
where \(I\) is the indicator function. For more details, see Section 2.1 of Park et al. (2024).
The left quantile is given by \(Q_L(u) = \inf\{t: F_w(t) \ge u\}\),
and the right quantile is given by \(Q_R(u) = \inf\{t: F_w(t) > u\}\).
Then, wmedian calculates \((1-a)Q_L(u) + aQ_R(u)\),
where \(a\) is the interpolation value.
References
F. Y. Edgeworth (1888).
On a New Method of Reducing Observations Relating to Several Quantities.
The London, Edinburgh, and Dublin Philosophical Magazine and Journal of Science,
25(154), 184-191.
Park, C., X. Gao, and M. Wang (2024).
Robust explicit estimators using the power-weighted repeated medians.
Journal of Applied Statistics, 51(8), 1590-1608.
tools:::Rd_expr_doi("10.1080/02664763.2023.2229969")