So I was trying to compute the quantiles from a dataset in R:


using the quantile() function, and I realised that it was returning unexpected quartile values for Q1 and Q3 (7 and 14, respectively, should be 6 and 16) on it's own. So I went into the documentation and saw you can assign a type to the function 1-9 that correspond to algorithms. By process of elimination type 6 yields the expected quantiles for that specific dataset, but due to my weak maths I don't actually understand the algorithms being used, and why type 6 specifically worked on my data type (more on those). Does a good explanation for when to use each type exist for someone really new to stats?


1 Answer 1


Why should the answers be $6$ and $16$? The $p^\text{th}$ quantile $q_p$ is the smallest value for which the proportion of the sample lesser than or equal to $q_p$ is at least $p$, and the proportion greater than or equal to $q_p$ is at most $1 - p$. If we take $p = 1/4$ and look at your sample $\{3, 5, 7, 8, 12, 13, 14, 18, 21 \}$, $7$ matches this definition but $6$ doesn't. The same is true for the $p = 3/4$ quantile.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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