Learn R Programming

groupcompare (version 1.0.1)

calcquantile: Sample Quantiles

Description

Calculates the quantiles (percentiles) for a given vector of data at specified fractions.

Usage

calcquantile(x, indices, Q = seq(0.1, 0.9, 0.1), qt = 7)

Value

Returns a numeric vector containing the calculated quantiles.

Arguments

x

Numeric vector containing the values to calculate quantiles.

indices

Optional; vector containing the indices for which the calculation will be performed.

Q

Probabilities for quantile levels. The default is seq(0.1, 0.9, 0.1)

qt

Type of quantile calculation. Integer between 0 and 9. Default: 7

Author

Zeynel Cebeci, A. Firat Ozdemir, Engin Yildiztepe

Details

This function calculates the quantiles at specified fractions of the given data set. If qt is 0, the hdqe function is used.

  • 0: Harrell-Davis estimator (not available in stats::quantile function).

  • 1: Inverse of the empirical distribution function.

  • 2: Similar to Type 1 but with averaging at discontinuities.

  • 3: Empirical distribution with sampling.

  • 4: Linear interpolation of the empirical distribution function.

  • 5: Linear interpolation of the expectations for the order statistics.

  • 6: Linear interpolation of the modes for the order statistics.

  • 7: The default in the stats::quantile function.

  • 8: Median-unbiased estimator.

  • 9: Normal-unbiased estimator.

For the details on types, see the quantile and hdqe functions.

References

Hyndman, R. J. and Fan, Y. (1996) Sample quantiles in statistical packages, American Statistician 50, 361--365. <doi:10.2307/2684934>.

See Also

quantile, hdqe

Examples

Run this code
x <- rnorm(100)
calcquantile(x)
calcquantile(x, qt=9)
calcquantile(x, qt = 0)

Run the code above in your browser using DataLab