First movement · Difference under the microscope

Exercise 2.1 · Median, quartiles and skewness

Median, boxplot, skewness

Data for this exercise — airquality.csv air readings from New York · stones.csv the twelve stones from the book · what each column means

hook

The middle that lies above the middle

mean · typical day · shape of the heap

New York, the summer of 1973. On a narrow island in the East River stands a measuring box that does the same thing every day: sniff, count, write down how much ozone is hanging in the air.1 Ozone at street level is the stuff smog is made of — the higher the number, the harder the city breathes. The box passes no judgement. All it does is collect a heap of numbers, a hundred and sixteen days long. And in the shape of that heap — for anyone who looks closely — sits the whole summer.

And now us. The first question anyone asks of a column like this is the one from the exercise on the mean: what is an average ozone day? Add up, divide, done: 42.1. A nice, tidy story — until you leaf through the column itself. It starts like this: 41, 36, 12, 18, 28, 23, 19, 8… mostly numbers that stay below 42, and then suddenly, further on, a day of 168. Count it: of the 116 days, only 44 come out above the mean. So the ‘average day’ is a day that most days don’t reach.

How can a middle lie above the middle? And what, then, is a typical ozone day in that summer? Come along for a moment — the answer isn’t in yet another number, but in the shape of the heap.

play with it

Two middles and two pictures in JASP

mean · median · quartiles · histogram · boxplot

NoteFirst as in the book — the twelve stones · JASP 0.99.0
  1. Descriptives, shine to Variables.
  2. Under Statistics, tick: Median, Quartiles.
  3. Under Customizable Plots: Boxplots.

Median 50, Q1 = 30, Q3 = 70 — the middle half lies in a band of 40 points.

The median of the shine is 50, with Q1 = 30 and Q3 = 70: the middle half of the stones sits in a band of 40 points, neatly symmetric around the middle. That’s what a boxplot looks like when nothing odd is going on.

Now you — with something you haven’t seen yet: air readings from New York. Those do lean to one side, and that is exactly when the median and the quartiles take on the work the mean fails at.

Bring the summer in and ask for two things: the middles, and a picture of the whole heap.

NoteIn JASP · give it a tug · JASP 0.99.0
  1. Open airquality.csv in JASP (menu top left → Open).
  2. Click Descriptives at the top.
  3. Drag ozone to the Variables box.
  4. Open the Statistics section and, next to Mean (arithmetic) (that one is already on), also tick Median, Quartiles and Skewness.
  5. Open the Basic Plots section and tick Distribution plots, and under Customizable Plots the Boxplots.

There they are, two middles side by side. The mean is 42.1. The median — lay all 116 days in order and take the middle one — is 31.5. Eleven points apart — for two numbers that both claim to be ‘the middle’. Add the quartiles: a quarter of the days stay below 18, a quarter come out above 63.25; in between lives the middle half of the summer.

And then the pictures. The histogram is no neat bell but a heap leaning against the left-hand side, with a long stretch trailing off to the right — plenty of clean days, a thin wisp of smog days. The boxplot sums that same heap up in five lines: a box from 18 to 63.25 with the median line low inside that box, a short whisker downwards, a long whisker upwards, and above that two more lone dots: 135 and 168. Everything there is to see points the same way. Up.

get it

Why the tail lifts the mean

right-skewed · balance point · robustness · choice of middle

What you’re looking at is called a right-skewed distribution. Careful: the skew is named after the tail, not after the hump. The hump leans left, but the tail points right — towards the high end — so right-skewed. (In a histogram lying flat; in the upright boxplot that same tail points up.)

And that tail explains the riddle from the hook. The mean, you see, is a balance point: every day pulls on it, and the further a day lies from the middle, the harder it pulls. Those few smog days — seven days of 100 or higher, with 168 as the champion — hang like weights on the end of a lever and lift the mean up to 42.1. The median doesn’t do levers. It only counts who sits above and who sits below, and says, unruffled: the middle day of this summer was 31.5.

Want to feel how unruffled? Thought experiment: suppose the top day hadn’t been 168 but a disastrous 500. The mean then jumps from 42.1 to 45.0 — one single day pushes the whole ‘middle’ up three points. And the median? It stays at exactly 31.5. There is still exactly one day above it on the high side, and that is all the median cares about. That’s what statisticians call robust: unmoved by what happens in the tail.

There was a hint in the numbers from the start, by the way. The standard deviation from the exercise on the mean is 33.0 here — almost as large as the mean itself. But ozone can’t go below zero: a symmetric bell around 42 with a spread of 33 would sink through the floor on the left. So the distribution couldn’t have been symmetric at all; the skew was already blinking in the summary before we had drawn a single picture.

When does the mean mislead? Right here — with skewed heaps. And the world is full of them: incomes (a handful of millionaires lifts the ‘average income’ above what almost everyone earns), waiting times, house prices, insurance claims. Wherever a distribution does have a long tail upwards and doesn’t have one downwards, the mean lies above the median and above most people’s experience. Compare it with the penguin weight from the exercise on the mean: mean 4202 grams, median 4050 — a few per cent apart, take your pick, it hardly mattered there. Here the difference is a third of the median. Hence the rule of this exercise: look at the shape of the heap first, and only then choose your middle.

One more nuance, because ‘the mean misleads’ is also too quick a verdict. Neither middle is wrong; they answer different questions. If you want to know how much ozone the city had to cope with that summer in total, the mean is exactly right — mean times number of days is the total, tail and all. If you want to know what a typical day was, what you’ll probably be breathing tomorrow, then the median should do the talking. In plain words: “the middle summer day had 31.5 parts of ozone per billion, but a handful of smog days — up to 168 — pulled the mean up to 42.” Whoever reports only ‘a mean of 42’ tells you about the tail and keeps quiet about the summer.

your turn

From smog to wind

median · quartiles · boxplot · describing shape

Your turn — from smog to wind. airquality.csv also holds the column wind (wind speed in miles per hour, the same 116 days). The same measures, a different heap — and this one is nowhere near as skewed.

First set up the analysis below, then answer the questions. In brackets, each time, is what belongs in a complete answer, so you can check yourself without opening our answer. Where it says more than one answer is right, the wording is up to you — for the rest, the answer is fixed. The last one is called Z) again: the assumptions always come last. And under Exam-style questions, at the end of this exercise, the same topics come round once more, in the form an exam would ask them in.

NoteIn JASP · the wind
  1. In the same Descriptives analysis, drag wind to the Variables box (and ozone out).
  2. Under Statistics, Median and Quartiles are already on; leave Mean (arithmetic) on as well. To check: Mdn = 9.70 with Q1 = 7.40 and Q3 = 11.50.
  3. Under Basic Plots the Distribution plots and under Customizable Plots the Boxplots are still on; leave them on.
NoteYour turn

a) Look up the median and the two quartiles of the wind. (three numbers, to two decimal places)

b) Work out the IQR. Why is that one number and not two? (one number, and one sentence)

c) Work out the mean as well and subtract the median from it. (two numbers, and which way the difference points)

d) Do that same subtraction for the ozone from this exercise. (one number, and one sentence on how the two compare)

e) How many of the 116 days lie above their own mean — for the wind, and for the ozone? (two numbers, each also as a percentage)

f) Look at the boxplot of the wind. How many lone dots stand outside it, and on which side? (one number, the side, and the values themselves)

g) At c) the wind looked almost symmetric, and yet all the dots stand on one side. Do those two contradict each other? (one sentence; whether you call 0.16 ‘almost symmetric’ is up to you, which way it points is not)

h) Look up the minimum and the maximum and set the distance between them next to the IQR. (three numbers, and one sentence on why they lie so far apart)

i) Which middle would you report for the wind, and which for the ozone? (two choices, with one sentence per choice)

j) Put the rule of thumb of this exercise into your own words. (one sentence, with the word shape in it; more than one answer is right)

k) Write a conclusion about what it all means, in no more than five sentences. (about the summer of 1973 — a number is allowed, as long as the unit is next to it; more than one answer is right)

Z) Can you believe everything above? Check:

  • are there readings missing in this column, and what does your program do then?
  • does every day measure the same thing — the same box, the same unit?
  • is this one heap, or are there seasons running through it?

And then the question that always belongs at the end: if something goes wrong, which answers above do you redo, and which may stand?

a) Mdn = 9.70, with Q1 = 7.40 and Q3 = 11.50. So the middle half of the summer days lives between a little over seven and eleven and a half miles per hour.

b) IQR = 11.50 − 7.40 = 4.10. It’s one number because it isn’t the box itself but its width — Q1 and Q3 tell you where the box lies, the IQR tells you how wide it is. That distinction is worth holding on to: two summers can have the same IQR and still lie somewhere else entirely.

c) M = 9.86, and 9.86 − 9.70 = 0.16. So the mean lies a fraction above the median — the same way round as with the ozone, but by sixteen hundredths of a mile per hour instead of a good ten parts per billion.

d) Ozone: 42.13 − 31.50 = 10.63. That is 65.59 times the 0.16 of the wind — divide the two rounded numbers on this line and you get 66, and that small difference is exactly why you round only at the end. The two columns come from the same file and cover the same 116 days. But those two differences are in different units — miles per hour against parts per billion — so that ‘sixty-six times’ puts apples next to oranges. If you want to lay them side by side fairly, divide each difference by the spread of its own column: for the wind that gives 0.045 and for the ozone 0.322. Those are two numbers without a unit, and those you may compare — the ozone remains a good seven times as skewed as the wind.

e) Wind: 54 of the 116 days, or 46.6% — nearly half, as it should be with a neat heap. Ozone: 44 of the 116, or 37.9%. That second number was the whole hook of this exercise: an ‘average day’ that most days don’t reach.

f) Three dots, all three at the top: 18.4, 20.1 and 20.7 miles per hour. At the bottom there isn’t a single one, and there hardly could be — the fence there lies at 7.40 − 1.5 × 4.10 = 1.25, and the calmest day of the summer still managed 2.3. Mind the difference between those two numbers: 1.25 is the fence, and the whisker runs to the furthest day that still falls inside that fence. So the lower whisker ends here at 2.3 and not at 1.25.

g) More than one answer is right, because the question hangs on a judgement: whether you find 0.16 miles per hour ‘almost symmetric’ is up to you. The direction is not. So no — the dots and the two middles point the same way, only much more gently. The wind too leans a little to the right; that’s exactly what the 0.16 at c) was already telling you. The difference from the ozone is not a difference in direction but in degree: skewness is not a switch that’s on or off. That degree is the soft part of the answer, and that’s why an exam can’t ask for it. The direction it can — see the exam-style questions at the end.

h) Minimum 2.3, maximum 20.7, so a distance of 18.4 — a good four times the IQR of 4.10. That’s as it should be: the distance between the extremes hangs on exactly two days, and there is nothing typical about the wilder of the two. The IQR counts only the middle half and pays those two no attention at all. That’s the same robustness the median showed with the ozone.

i) For the wind it makes no difference — the two middles differ by 0.16, so by all means pick the mean, with the standard deviation beside it. For the ozone the median should do the talking, with the quartiles beside it, because there the two middles are a third apart and the mean says more about the seven smog days than about the summer.

j) More than one answer is right; there’s no prescribed wording. For example: look at the shape of the heap first, and only then choose your middle — and if the mean and the median barely differ, the shape has just told you that the choice doesn’t matter.

k) More than one answer is right. Numbers are allowed — the point is that next to every number it says what it measures, because ‘9.70’ is nothing and ‘9.70 miles per hour on the middle day’ is a summer. For example: in the summer of 1973 the wind on Roosevelt Island blew at 9.70 miles per hour on the middle day, and half of all days sat between 7.40 and 11.50 miles per hour. That heap is nearly symmetric: the mean lies 0.16 miles per hour above the middle day, on a range running from 2.3 to 20.7. Three days stuck out at 18.4, 20.1 and 20.7 miles per hour, but they barely dragged the middle along. For the ozone from the same summer the mean lay 10.63 parts per billion above the middle day — the same 116 days, two columns, two shapes.

Z) Yes, and just as in Exercise 1.1 without a distributional assumption: nothing here has been tested, only described. Each of the three questions does take a bite out of it here, though.

  • Stands: a) up to and including j). In the column wind not one of the 116 readings is missing, so you’re working with every day. That can’t be taken for granted here: in the column solar_r of this file, five are missing. What your program does with a gap like that — refuse, or quietly carry on — you can read in the box What is switched on? of Exercise 1.1.
  • Stands, with a warning attached: the median of 9.70 as ‘the typical summer day’, and with it k). These 116 days run from May to September, and that is not one homogeneous heap: per month the median lies at 11.50 (May), 11.50 (June), 7.70 (July), 8.00 (August) and 10.30 (September). So there is clearly less wind in July and August than in spring. That 9.70 is a correct number for the summer as a whole, and at the same time a day that is not particularly typical of any single month — exactly the same pitfall as the mean that mixed three penguin species.

What does not fall over is the measuring itself: it’s one box on one island, the same every day, in the same unit. That’s the dullest of the three questions and usually the most important — change what you’re measuring halfway through, and no measure of spread can help you any more.

reporting

Write it up like a researcher

Mdn · IQR · reporting a skewed distribution

NoteReporting

Remember from Exercise 1.1: reporting is a shopping list in sentence form. But with a skewed heap there’s something different on the list: not M and SD, but the shape, the median and the quartiles. Look:

The ozone concentration (in ppb) on the 116 measured summer days was right-skewed (Mdn = 31.50, IQR = 45.25; the middle half of the days lay between Q1 = 18.00 and Q3 = 63.25).

That’s it. One sentence that stands on its own feet: which days, which variable, the shape, the robust middle, and in brackets the box of the boxplot — how wide it is and where it lies. Mdn is the proper abbreviation for the median. Q1 and Q3 are the lower and the upper quartile: the two edges of the box. And IQR (interquartile range) is not that box itself but its width — 63.25 − 18.00 = 45.25. In the model sentence only the symbols are in italics; the ordinary words stay upright. And do you see what’s quietly going on? By reporting the median instead of the mean, the whole shape story is already tucked away inside the sentence.

Your turn: write a sentence like that yourself for the wind, in miles per hour (Mdn = 9.70, IQR = 4.10; the middle half of the days lay between Q1 = 7.40 and Q3 = 11.50). Choose deliberately which middle you report, now that you know the shape.

exam practice

Exam-style questions

choice of middle · robustness · 1.5 × IQR · direction of the skew

These six have the form an exam would ask this topic in: four options, and exactly one is the best — the other three may well be true and still not the best answer. Only question 3 needs any arithmetic.

NoteExam-style questions

1. You’re reporting the ozone of these 116 days and have to choose one middle. Which description is the best?

  1. The median, because with a skewed distribution you aren’t allowed to use the mean.
  2. The median, because it gives the typical day, while the smog days have pulled the mean upwards.
  3. The mean, because it uses all 116 days and the median throws information away.
  4. It makes no difference: M = 42.13 and Mdn = 31.50 lie less than one standard deviation (SD = 32.99) apart.

2. In the boxplot of the wind there are three lone dots, all three at the top, and the mean lies 0.16 miles per hour above the median. Which statement about the shape of the wind heap is the best?

  1. The wind heap is symmetric; three lone dots on one side say nothing about the shape.
  2. The wind heap leans slightly to the right: the dots and the two middles point the same way.
  3. The wind heap is right-skewed, because as soon as there are dots on one side a distribution is skewed.
  4. The wind heap is left-skewed, because the median (9.70) lies below the mean (9.86).

3. For the wind, Q1 = 7.40 and Q3 = 11.50 miles per hour, so IQR = 4.10 miles per hour. A day counts as a lone point above the whisker as soon as it comes out above Q3 + 1.5 × IQR. Which of these four wind days is the lowest one that still lies above that?

  1. 14.9 miles per hour
  2. 16.6 miles per hour
  3. 18.4 miles per hour
  4. 20.1 miles per hour

4. In your mind, lift the top day of the ozone from 168 to 500 ppb. The mean then climbs from 42.13 to 44.99, and the median stays put at 31.50. What is the reason?

  1. The median counts how many days lie above and below, not how far away they lie.
  2. The median leaves days out of the calculation as soon as they come out above Q3 + 1.5 × IQR.
  3. The median is calculated over the middle half of the days, so the tail doesn’t count.
  4. The median stays put as long as there are equally many days on both sides.

5. The IQR of the ozone is 45.25 ppb and that of the wind 4.10 miles per hour. What does the IQR say about a distribution?

  1. Where the middle half of the readings lies.
  2. How wide the middle half of the readings is.
  3. The difference between the highest and the lowest reading, divided by four.
  4. How far the furthest lone point lies from the median.

6. Of the ozone you know only this: the mean is 42.13 ppb, the highest day was 168 ppb, and an ozone reading can’t go below zero. What may you conclude from that about the shape of the ozone heap, before you have drawn a single picture?

  1. Nothing — for the shape of a distribution you need a histogram or a boxplot.
  2. The ozone heap can’t be symmetric: a day as far below the mean as 168 is above it would come out at −83.74 ppb.
  3. The ozone heap is symmetric, because 42.13 lies roughly midway between zero and the highest day.
  4. The ozone heap is left-skewed, because there’s more room above the mean than below it.

1 b · 2 b · 3 c · 4 a · 5 b · 6 b

Below, for each question, is why — and why the other three options are tempting. If you got one right, you can skip it.

1. b. The median gives the typical day, and the seven days of 100 ppb or higher have pulled the mean to 42.13. a picks the same middle on the strength of a ban that doesn’t exist: a mean is allowed with a skewed heap, it just answers a different question. If you want to know how much ozone the city had to cope with that summer in total, the mean is exactly right — mean times number of days is that total. That’s the difference between wrong and a different question, and an exam asks about that difference. c is right in what it claims — the mean really does use all 116 days — and draws the wrong conclusion from it; ‘more days included’ is not the same as ‘better middle’. d tempts you with a real calculation: 10.63 really is less than 32.99. But that says nothing, because that SD of 32.99 is itself inflated by the very tail that causes the problem.

2. b. Direction: right. Degree: small. a throws the dots away while they count as a clue. c turns skewness into a switch that’s on or off, and it isn’t one — the wind leans the same way as the ozone, and a seventh as far. d has the right reason and the wrong label: the median lying below the mean is exactly what right-skewed means. That’s the confusion that names the skew after the hump instead of after the tail.

3. c. The fence lies at 11.50 + 1.5 × 4.10 = 17.65 miles per hour, and 18.4 is the lowest wind day that comes out above it. a and b are both days of hard wind that still fall inside the whisker — 14.9 and 16.6 stay below 17.65, and high here is not the same as lone point. That b lies so close is no accident: 16.6 is the highest day that still just falls inside, and that one draws the end of the line. So the whisker stops at 16.6 and not at 17.65. d is a lone point, only not the lowest of the three — the question asks for the first one that falls outside, not the worst.

4. a. The median counts places in the row, not distances. Whether the top day is 168 or 500: equally many days lie above the median, so the middle day doesn’t change. The mean does count distances, and so climbs to 44.99. b confuses robustness with crossing out: the 1.5 × IQR rule decides what gets drawn as a lone point in a boxplot, but the median throws nothing away — that 500 simply takes part, it just counts as one day and not as a far-off day. c mixes the median up with the IQR; the median uses all 116 days. (And it gives a different number: the median of only the middle half is 31.00, not 31.50.) d sounds right and can’t be: above and below the median there are by definition always equally many days — that’s what a median is, not a condition it has to meet.

5. b. The IQR is Q3 − Q1, so the width of the box. a is the answer almost everyone gives first, and it’s the position: where the middle half lies is what Q1 and Q3 tell you. Two summers can have the same IQR of 4.10 and still lie somewhere else entirely. c sounds like a quartile sum but isn’t one; the range divided by four hangs on the two extreme days, and that’s exactly what the IQR doesn’t do. d measures from the median to a lone point and so uses the tail, of all things.

6. b. In a symmetric heap, for every day above the mean there’s a day just as far below it. The top day of 168 lies 168 − 42.13 = 125.87 above the mean, so its mirror image would lie at 42.13 − 125.87 = −83.74 ppb. No such day exists: ozone stops at zero. So the heap can’t be symmetric, and you knew that before the histogram. a is the safe habit and too modest here: a floor that nature lays down is itself information about the shape. c is the most tempting, because it sounds like a test for symmetry — but work it out: the midpoint between zero and the highest day lies at 84.00 ppb, and the mean lies at 42.13 ppb, so 41.87 ppb lower. In a symmetric heap those two coincide. That they lie so far apart here points to skewness. d sniffs out the skew correctly and sticks the wrong label on it: the room is at the top, so the tail points right, and that’s called right-skewed.

If you want to see for yourself where the numbers from these six questions come from: the sums in answers 3 and 6 are written out in full above, and those you can check with your calculator. Question 4 can be done with the calculator too, and then you see straight away why the mean shifts. The mean is the sum of all 116 days, divided by 116. If one day becomes 500 − 168 = 332 ppb heavier, the mean shifts by 332 / 116 = 2.86: 42.13 + 2.86 = 44.99. The median doesn’t shift, because the middle day stays the same day.

NoteIn JASP · the wind days around the fence
  1. Click the funnel above the data and type in the R box wind <= 17.65. Put wind in Descriptives: next to Maximum you’ll find 16.600, the highest day that still falls inside the whisker.
  2. Change the filter to wind > 17.65: next to Minimum you’ll find 18.400, the lowest that falls outside.
  3. Switch the filter off again afterwards — otherwise everything after this is computed on only a handful of days.

And this is how you check the two numbers from answer d) of Your turn: divide the difference between mean and median by the standard deviation of the same column, as Descriptives shows it.

  • wind: 0.16 / 3.575 = 0.045
  • ozone: 10.63 / 32.988 = 0.322

◠ Same shape in the book

Here: two middles pulling apart, and the heap that gives away why.

In the book: Chapter 2 — The Shape of the Heap

There you learn to read distributions before you summarise them — first the shape, then the number that may stand for the shape.

Footnotes

  1. Daily ozone readings in ppb (parts per billion) on Roosevelt Island, New York, May–September 1973; New York State Department of Conservation / National Weather Service. Available as the classic R dataset airquality; these are the 116 days on which the ozone reading succeeded. Every number in this exercise has been recomputed on that real data.↩︎