0

Does outliers begin on the whisker limit or above it?

In the (Python) example below the calculcated upper whisker limit is 64.8125. Is a value of 64.8125 an outlier (>= upper_limit)? Or the outliers are higher then the limit (> upper_limit)?

>>> import seaborn as sns
>>> df = sns.load_dataset('titanic)

>>> df.age.quantile([.25, .5, .75]) 0.25 20.125 0.50 28.000 0.75 38.000 Name: age, dtype: float64

>>> q1, q2, q3 = df.age.quantile([.25, .5, .75]) >>> iqr = q3 - q1 >>> whisker_length = iqr * 1.5

>>> upper_limit = q3 + whisker_length >>> lower_limit = q1 - whisker_length >>> lower_limit, upper_limit (-6.6875, 64.8125)

buhtz
  • 232
  • related https://stats.stackexchange.com/a/603446/56940 – utobi Apr 18 '23 at 09:11
  • No it don't because it doesn't fit to my MWE. – buhtz Apr 18 '23 at 11:40
  • 2
    What is an "MWE" and why should it matter here? BTW, I found the duplicate threads by searching for "boxplot fence" and "boxplot whisker outlier" and looking at the top-voted hits. I'm sure you can find even more answers by searching further. – whuber Apr 18 '23 at 13:00
  • MWE = https://stackoverflow.com/help/minimal-reproducible-example – buhtz Apr 18 '23 at 14:04
  • 1
    I thought it might be that, but your example is by no means "minimal." – whuber Apr 19 '23 at 15:32

1 Answers1

2

Under Tukey's approach, the whiskers are specifically drawn in each direction to the furthest observation from the median that is still within (or equal to) the inner fence. If a point is exactly on the inner fence, the whisker includes it.

A marked point must therefore be outside the inner fences.

That is strictly above on the high side (above the upper inner fence) but strictly below on the low side (below the lower inner fence).

Here's an illustration where there's points above the upper inner fence.

Box plot with calculation of inner fence shows and showing points strictly outside the fences marked with circles

Glen_b
  • 282,281
  • Can you please fit your answer to my MWE and give a number. – buhtz Apr 18 '23 at 08:51
  • 6
    No. ... That looks like I'd be doing homework. I believe my answer is unambiguous. – Glen_b Apr 18 '23 at 08:52
  • I'm far behind homework. I just try to "translate" it into my world. I know Tukey of course. But I don't "speak" math. Also English isn't my nativ language. So I just want to be sure if I understand it correct. My assumption is > upper_limit but I'm not sure without confirmation based on my MWE. – buhtz Apr 18 '23 at 09:45