5
$\begingroup$

I read the boxplot docs, but didn't find the answer.

When using the default settings (boxplot(x.ts)), what do the whiskers, boxes, midlines and outliers represent? Does it show quartiles or standard deviations?

Where is this documented?

$\endgroup$
0

2 Answers 2

8
$\begingroup$

The documentation seems fairly clear to me, although it certainly helps to be familiar with how to read R documentation and with boxplots more generally. Towards the bottom of the page it says:

See Also

boxplot.stats which does the computation...

So we can navigate there. It reads:

Details

The two ‘hinges’ are versions of the first and third quartile, i.e., close to quantile(x, c(1,3)/4). The hinges equal the quartiles for odd n (where n <- length(x)) and differ for even n. Whereas the quartiles only equal observations for n %% 4 == 1 (n = 1 mod 4), the hinges do so additionally for n %% 4 == 2 (n = 2 mod 4), and are in the middle of two observations otherwise.

And the Values section includes:

stats a vector of length 5, containing the extreme of the lower whisker, the lower ‘hinge’, the median, the upper ‘hinge’ and the extreme of the upper whisker.

Moreover, above that we see that the argument coef is set to 1.5 by default (so that is what you would get unless you had changed the default for range in the original boxplot call). The coef argument is documented:

coef this determines how far the plot ‘whiskers’ extend out from the box. If coef is positive, the whiskers extend to the most extreme data point which is no more than coef times the length of the box away from the box. A value of zero causes the whiskers to extend to the data extremes (and no outliers be returned).

From these, we learn that the midline is the median of your data, with the upper and lower limits of the box being the third and first quartile1 (75th and 25th percentile) respectively. By default, the whiskers will extend up to 1.5 times the interquartile range from the top (bottom) of the box to the furthest datum within that distance. If there are any data beyond that distance, they are represented individually as points ('outliers').

To be explicit, they do not show standard deviations.

1. Note that determining the value for a quantile (e.g., the 25th percentile is potentially more complicated than people realize. There are at least nine different methods that have been discussed. For a nice overview, see @Glen_b's excellent answer here: Relation between Quintiles and the Arithmetic Mean.

$\endgroup$
3
$\begingroup$

enter image description here

This sums up the box plot and what each line represents.

Source: http://www.physics.csbsju.edu/stats/box2.html

$\endgroup$
4
  • 4
    $\begingroup$ The ends of the whiskers may not be the minimum and maximum values. $\endgroup$ Jan 3, 2016 at 16:46
  • 2
    $\begingroup$ true - there may be outliers $\endgroup$ Jan 3, 2016 at 16:49
  • 5
    $\begingroup$ This answer is wrong. $\endgroup$
    – SmallChess
    Jul 27, 2017 at 8:14
  • $\begingroup$ I don't think this answer should have three upvotes - it is wrong as the ends of the whiskers do not necessarily go to the minimum and maximum. $\endgroup$
    – bob
    May 26, 2021 at 0:40

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