4
$\begingroup$

I just realized that in R, the quantile function offers different types of quantiles. In my first statistics class, I learned the definition of a quantile being that value below which a given percentage of values fall. Now it seems like there are other definitions. If correct, what do these definitions have in common? Asked differently, abstractly speaking what is a quantile so that all 9 types of quantile algorithms capture that definition?

I read this article but it doesn't really address the question of a more abstract definition of quantile that encompasses, for example, all 9 types of the R function.

$\endgroup$
1

1 Answer 1

3
$\begingroup$

There is no single definition of quantile that is universally agreed upon. The basic idea is that the $q$th sample quantile has no more than the fraction $q$ of the $n$ observations below the quantile and no more than the fraction $1-q$ of them above.

However, especially when $qn$ is not an integer and/or there are ties, this rule does not give a unique result. The different 'types' available in R provide more specific rules. [See R documentation under types for some explanations of differences.]

Ostensibly, each of the types has optimum properties for certain kinds of distributions or for certain applications where quantiles are used. Last I checked SAS, Excel, Minitab, Stata, and R (default) used various different types.

For large $n$ the various types give very similar answers.

  • If you are taking a class in which there are specific exercises about finding quantiles, then be sure you know what definition your text or class notes says to use, and don't be surprised if different kinds of statistical software (and Internet 'calculators') don't give the same answer you are expected to provide.

  • If you are not a student, you may never have to be concerned about the different styles of quantiles.

Brief demo:

set.seed(2020)
x = rbinom(19, 10, .5);  sort(x)
[1] 1 3 3 3 5 5 5 5 5 5 5 5 5 6 6 6 6 6 8

quantile(x, type=3)
  0%  25%  50%  75% 100% 
   1    5    5    6    8 
quantile(x, type=4)
  0%  25%  50%  75% 100% 
 1.0  4.5  5.0  6.0  8.0 
quantile(x, type=7)      # Default type in R
  0%  25%  50%  75% 100% 
   1    5    5    6    8 

y = rnorm(1000, 100, 15)
stripchart(y, pch="|")

enter image description here

quantile(y, type=1)
       0%       25%       50%       75%      100% 
 53.14844  89.73115 100.02494 110.02682 166.42994 
quantile(y, type=2)
       0%       25%       50%       75%      100% 
 53.14844  89.73583 100.07829 110.02721 166.42994 
quantile(y, type=3)
       0%       25%       50%       75%      100% 
 53.14844  89.73115 100.02494 110.02682 166.42994 
quantile(y)  # type 7 by default
       0%       25%       50%       75%      100% 
 53.14844  89.73816 100.07829 110.02702 166.42994 
$\endgroup$
2

Not the answer you're looking for? Browse other questions tagged or ask your own question.