calcquantdif | R Documentation |
Calculates the differences between specified quantiles for grouped data.
calcquantdif(x, indices, Q=seq(0.1, 0.9, 0.1), qt=7)
x |
A data frame or matrix containing the input data. The first column should be the variable of interest, and the second column should be the grouping variable. |
indices |
Optional; specific rows to be considered. If not provided, all rows are used. |
Q |
A numeric vector specifying the quantiles to be computed. The default is |
qt |
An integer specifying the quantile type from 0 to 9. The default is type 7, as discussed by Hyndman and Fan (1996)<doi:10.2307/2684934>. |
This function calculates the differences between specified quantiles for groups defined by the second column of the input data. It uses the specified quantile type to compute the quantiles. Types of quantiles are:
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
function.
A numeric vector containing the differences between the specified quantiles for each group.
Zeynel Cebeci, A. Firat Ozdemir, Engin Yildiztepe
Hyndman, R. J. and Fan, Y. (1996) Sample quantiles in statistical packages, American Statistician, 50, 361-365. <doi:10.2307/2684934>.
quantile
, hdqe
, calcstatdif
df <- data.frame(value = rnorm(100), group = rep(1:2, each = 50))
# Difference between the medians
mediandif <- calcquantdif(df, Q=0.5)
mediandif
# Differences between the quartiles
quantdifs <- calcquantdif(df, Q=c(0.25, 0.5, 0.75))
quantdifs
# Differences between the percentiles from P10 to P90 using the method 5
quants <- seq(0.1, 0.9, 0.1)
quantdifs <- calcquantdif(df, Q=quants, qt=5)
quantdifs
# Differences between the percentiles from P10 to P90 using the method Harrell-Davis
quants <- seq(0.1, 0.9, 0.1)
quantdifs <- calcquantdif(df, Q=quants, qt=0)
quantdifs
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.