Learn R Programming

simPop (version 0.2.6)

quantileWt: Weighted sample quantiles

Description

Compute quantiles taking into account sample weights.

Usage

quantileWt(x, ...)

## S3 method for class 'default': quantileWt(x, weights=NULL, probs=seq(0, 1, 0.25), na.rm=TRUE, ...)

## S3 method for class 'dataObj': quantileWt(x, vars, probs=seq(0, 1, 0.25), na.rm = TRUE, ...)

Arguments

x
a numeric vector.
weights
an optional numeric vector containing sample weights.
vars
a character vector of length 1 specifying a variable name that is available in the data-slot of x and which is used for the calculation.
probs
a numeric vector of probabilities with values in $[0, 1]$.
na.rm
a logical indicating whether any NA or NaN values should be removed from x before the quantiles are computed. Note that the default is TRUE, contrary to the function
...
for the generic function quantileWt additional arguments to be passed to methods. Additional arguments not included in the definition of the methods are currently ignored.

Value

  • A vector of the (weighted) sample quantiles.

Details

If weights are not specified then quantile(x, probs, na.rm=na.rm, names=FALSE, type=1) is used for the computation.

Note probabilities outside $[0, 1]$ cause an error.

See Also

quantile

Examples

Run this code
data(eusilcS)
(quantileWt(eusilcS$netIncome, weights=eusilcS$rb050))

# dataObj-method
inp <- specifyInput(data=eusilcS, hhid="db030", hhsize="hsize", strata="db040", weight="db090")
(quantileWt(inp, vars="netIncome"))

Run the code above in your browser using DataLab