weighted_median: Weighted median with weighted interpolation

Description Usage Arguments Details Value See Also Examples

View source: R/robsurvey.R

Description

weighted_median computes a weighted median where the exact location corresponds exactly to a cumulative weight of 0.5. This yields a symmetric median.

Usage

1
weighted_median(x, w, na.rm = FALSE)

Arguments

x

a numeric vector whose weighted sample median is wanted

w

a numeric vector of weights

na.rm

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

Details

Note that the weighted_median function delivers a symmetric median while the weighted_quantile function with probability 0.5 delivers the lower median. Hence, the results of these two functions will generally differ.

Value

weighted sample median

See Also

weighted_quantile

Examples

1
2
x <- c(0.1, 0.35, 0.05, 0.1, 0.15, 0.05, 0.2)
weighted_median(x, x)

martinSter/robsurvey documentation built on Oct. 11, 2019, 4:45 p.m.