Learn R Programming

berryFunctions (version 1.7.1)

quantileMean: Average of R's quantile methods

Description

weighted average of R's quantile methods

Usage

quantileMean(x, probs = seq(0, 1, 0.25), weights=rep(1,9), names=TRUE, ... )

Arguments

x
Numeric vector whose sample quantiles are wanted
probs
Numeric vector of probabilities with values in [0,1]. DEFAULT: seq(0, 1, 0.25)
weights
Numeric vetor of length 9 with weight for each quantile method. Recycled if shorter. DEFAULT: unweighted mean. DEFAULT: rep(1,9)
names
If TRUE, the result has a names attribute. Set to FALSE for speedup with many probs.. DEFAULT: TRUE
...
further arguments passed to quantile, except for type

Value

  • numeric named vector, as returned by apply

Details

weights are internally normalized to sum 1

See Also

quantile

Examples

Run this code
exDat <- rnorm(30,sd=5)
quantile(exDat, probs=c(0.9, 0.99), type=1)
quantile(exDat, probs=c(0.9, 0.99), type=2)
round( sapply(1:9, function(m) quantile(exDat, probs=0.9, type=m)) , 3)
# and now the unweighted average:
quantileMean(exDat, probs=c(0.9, 0.99))
quantileMean(exDat, probs=0.9)
# say I trust type 2 and 3 especially and want to add a touch of 7:
quantileMean(exDat, probs=c(0.9, 0.99), weights=c(1,5,5,0,1,1,3,1,1))

Run the code above in your browser using DataLab