The OpenD Programming Language

QuantileAlgo

Algorithms used to calculate the quantile of an input x at probability p.

These algorithms match the same provided in R's (as of version 3.6.2) quantile function. In turn, these were discussed in Hyndman and Fan (1996).

All sample quantiles are defined as weighted averages of consecutive order statistics. For each quantileAlgo, the sample quantile is given by (using R's 1-based indexing notation):

(1 - gamma) * x$(SUBSCRIPT j) + gamma * x$(SUBSCRIPT j + 1)

More...

Values

ValueMeaning
type1

Discontinuous sample quantile

Inverse of empirical distribution function.

type2

Similar to type1, but averages at discontinuities.

type3

SAS definition: nearest even order statistic.

type4

Continuous sample quantile

Linear interpolation of the empirical cdf.

type5

A piece-wise linear function hwere the knots are the values midway through the steps of the empirical cdf. Popular amongst hydrologists.

type6

Used by Minitab and by SPSS.

type7

This is used by S and is the default for R.

type8

The resulting quantile estimates are approximately median-unbiased regardless of the distribution of the input. Preferred by Hyndman and Fan (1996).

type9

The resulting quantile estimates are approximately unbiased for the expected order statistics of the input is normally distributed.

Detailed Description

where x$(SUBSCRIPT j) is the jth order statistic. gamma is a function of j = floor(np + m) and g = np + m - j where n is the sample size, p is the probability, and m is a constant determined by the quantile type.

$(T3 type1, 0, 0 if `g = 0` and 1 otherwise.) $(T3 type2, 0, 0.5 if `g = 0` and 1 otherwise.) $(T3 type3, -0.5, 0 if `g = 0` and `j` is even and 1 otherwise.)

$(T3 type4, 0, `gamma = g`) $(T3 type5, 0.5, `gamma = g`) $(T3 type6, `p`, `gamma = g`) $(T3 type7, `1 - p`, `gamma = g`) $(T3 type8, `(p + 1) / 3`, `gamma = g`) $(T3 type9, `p / 4 + 3 / 8`, `gamma = g`)

Typemgamma
Discontinuous sample quantile
Continuous sample quantile

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

See Also

Meta