1

I am following an example at KhanAcademy.com regarding box plots.

I tried to simulate the question in R with the following code

x <- c(13,9,11,8,8,12,9,9,4,12,10,8,11)
summary(x)
Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
4.000   8.000   9.000   9.538  11.000  13.000 

Sal of KA stated that there are two ways of getting the quadrilles the difference being whether one factors in the median when computing the 1st and 3rd quartile.

Is there a way to tell the summary function you want to exclude the median when computing the other quartiles.

The answer if this approach is taken would be

Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
4.000   8.000   9.000   9.538  *11.500*  13.000 

How come there isn't an agreed method on how to tackle such problems?

chribonn
  • 445
  • 5
  • 20
  • 3
    This - http://chemicalstatistician.wordpress.com/2013/08/12/exploratory-data-analysis-the-5-number-summary-two-different-methods-in-r-2/ - has a good explanation regarding the differences between `summary`, `fivenum` and the `quantile` function that may be of help to you. `?quantile` also explains (somewhat) your `why` question, though that question shld be posed on [Cross Validated](http://stats.stackexchange.com/) – hrbrmstr Sep 29 '14 at 10:16

1 Answers1

1

There are actually 9 types of quantile available in R. See ?quantile for more information on how they are defined, which statistical software implements which ones, and a reference for their derivation. You can see them all here:

t(sapply(1:9, function(y) quantile(x,type=y)))
      0% 25% 50%      75% 100%
 [1,]  4   8   9 11.00000   13
 [2,]  4   8   9 11.00000   13
 [3,]  4   8   9 11.00000   13
 [4,]  4   8   9 11.00000   13
 [5,]  4   8   9 11.25000   13
 [6,]  4   8   9 11.50000   13
 [7,]  4   8   9 11.00000   13
 [8,]  4   8   9 11.33333   13
 [9,]  4   8   9 11.31250   13

As you will notice, for your data there is only variation in the 3rd quartile. The default for R is type 7, and that is what you will get from summary.

James
  • 65,548
  • 14
  • 155
  • 193