weighted.quantile: Quantiles of a weighted cdf

View source: R/weighted.quantile.R

weighted.quantileR Documentation

Quantiles of a weighted cdf

Description

A weighted cdf is calculated and quantiles are evaluated. Missing values are discarded.

Usage

weighted.quantile(x, w, prob = 0.5, plot = FALSE)

Arguments

x

a vector of data.

w

a vector of (sampling) weights.

prob

the probability for the quantile.

plot

if TRUE, the weighted cdf is plotted.

Details

Weighted linear interpolation in case of non-unique inverse. Gives a warning when the contribution of the weight of the smallest observation to the total weight is larger than prob.

Value

The quantile according to prob (by default it returns the weighted median).

Note

No variance calculation.

Author(s)

Beat Hulliger

See Also

svyquantile

Examples

x <- rnorm(100)
x[sample(1:100, 20)] <- NA
w <- rchisq(100, 2)
weighted.quantile(x, w, 0.2, TRUE)

modi documentation built on March 31, 2023, 8:35 p.m.