Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

wquantile

Weighted quantiles


Description

Functions to compute weighted quantiles and the weighted interquartile range.

Usage

wquantile(wt = rep(1,length(x)), x, probs, already.sorted = FALSE, 
          already.normalized = FALSE)
wIQR(wt = rep(1,length(x)), x, already.sorted = FALSE, 
     already.normalized = FALSE)

Arguments

wt

Vector of weights

x

Vector of data, same length as wt

probs

Numeric vector of probabilities with values in [0,1].

already.sorted

If FALSE, sort wt and x in increasing order of x. If TRUE, it is assumed that wt and x are already sorted.

already.normalized

If FALSE, normalize wt by diving each entry by the sum of all entries. If TRUE, it is assumed that sum(wt)==1

Details

wquantile uses the findInterval function. wIQR calls the wquantile function.

Value

Returns the sample quantiles or interquartile range of a discrete distribution with support points x and corresponding probability masses wt

See Also

Examples

IQR(1:10)
wIQR(x=1:10) # Note:  Different algorithm than IQR function
wIQR(1:10,1:10) # Weighted quartiles are now 4 and 8

mixtools

Tools for Analyzing Finite Mixture Models

v1.2.0
GPL (>= 2)
Authors
Derek Young [aut, cre] (<https://orcid.org/0000-0002-3048-3803>), Tatiana Benaglia [aut], Didier Chauveau [aut], David Hunter [aut], Ryan Elmore [ctb], Thomas Hettmansperger [ctb], Hoben Thomas [ctb], Fengjuan Xuan [ctb]
Initial release
2020-02-05

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.