calcquantdif {groupcompare}R Documentation

Quantile Differences

Description

Calculates the differences between specified quantiles for grouped data.

Usage

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

Arguments

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 seq(0.1, 0.9, 0.1).

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>.

Details

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:

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

Value

A numeric vector containing the differences between the specified quantiles for each group.

Author(s)

Zeynel Cebeci, A. Firat Ozdemir, Engin Yildiztepe

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, calcstatdif

Examples

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

[Package groupcompare version 1.0.1 Index]