weightedQuantile: Weighted Quantiles.

kish_essR Documentation

Weighted Quantiles.

Description

Computes weighted quantiles. whdquantile() uses a weighted Harrell-Davis quantile estimator. wthdquantile() uses a weighted trimmed Harrell-Davis quantile estimator. wquantile() uses a weighted traditional quantile estimator.

Usage

kish_ess(w)

wquantile_generic(x, w, probs, cdf)

whdquantile(x, w, probs)

wthdquantile(x, w, probs, width = 1/sqrt(kish_ess(w)))

wquantile(x, w, probs, type = 7)

Arguments

w

Numeric vector of weights to give each value. Should be the same length as the vector of values.

x

Numeric vector of values of which to determine the quantiles.

probs

Numeric vector of the quantiles to retrieve.

cdf

Cumulative distribution function.

width

Numeric value for the width of the interval in the trimmed Harrell-Davis quantile estimator.

type

Numeric value for type of weighted quantile.

Details

Computes weighted quantiles according to Akinshin (2023).

Value

Numeric vector of specified quantiles.

See Also

\Sexpr[results=rd]{tools:::Rd_expr_doi("10.48550/arXiv.2304.07265")}

Other computations: Mode(), meanSum(), mySum()

Examples

mydata <- c(1:100, 1000)
mydataWithNAs <- mydata
mydataWithNAs[c(1,5,7)] <- NA
weights <- rep(1, length(mydata))
quantiles <- c(0.01, 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99)

whdquantile(
  x = mydata,
  w = weights,
  probs = quantiles)

wthdquantile(
  x = mydata,
  w = weights,
  probs = quantiles)

wquantile(
  x = mydata,
  w = weights,
  probs = quantiles)

whdquantile(
  x = mydataWithNAs,
  w = weights,
  probs = quantiles)

wthdquantile(
  x = mydataWithNAs,
  w = weights,
  probs = quantiles)

wquantile(
  x = mydataWithNAs,
  w = weights,
  probs = quantiles)


petersenlab documentation built on April 4, 2025, 12:22 a.m.