Solved – How to calculate quartiles and other percentiles

quantiles

Given the following data:

972, 975, 985, 993, 993, 995, 998, 1001, 1004, 1007, 1008, 1009, 1011, 1015, 1016, 1020, 1022, 1032

I calculate the lower quartile as follows:

Number of values: 18, Number of 'gaps': 17.

Lower quartile is at 17/4 + 1 = 5.25th value.
5.25th value is 993 + (995 – 993) x 0.25 = 993.5

Upper quartile is at 3 x 17/4 + 1 = 13.75th value.
13.75th value is 1011 + (1015 – 1011) x 0.75 = 1014

Both the Excel QUARTILE function and the R quantile function agree with me. However the book I am using (Understanding Statistics by Graham Upton and Ian Cook) give different answers (993 and 1015 respectively). I'm confused. Which is correct?

Best Answer

As noted by Hyndman and Fan (1996) there are multiple definition of quantiles and different implementations, so it is very likely that you found different estimates calculated from the same data (each of them equally "correct"). I'm afraid that to mention all the differences I'd need to literally reproduce the paper in here, so maybe you should rather read it yourself, as it is available online:

Hyndman, R.J., & Fan, Y. (1996). Sample Quantiles in Statistical Packages. American Statistician, 50(4): 361-365.

Notice that quantile function for R (in fact implemented by Hyndman) enables you to calculate all the nine types of quantiles (using type parameter), check ?quantile to read more. So even R gave you only one of the possible estimates.

As about the estimates, types 1, 2, 3, 5, 6, 8, and 9 return the values reproduced in your book, type 7 (default in quantile function for R) is what you obtained and type 4 disagrees with both estimates.

Estimates of quantiles using different methods

Related Question