wIQR {mixtools}R Documentation

Weighted Interquartile Range

Description

Function to compute a weighted interquartile range.

Usage

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
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

Uses the findInterval function.

Value

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

See Also

npEM

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

[Package mixtools version 0.3.2 Index]