The Art of Statistics

David Spiegelhalter, How to Learn from Data (2019). The key visuals, chapter by chapter.Rahul's Site
0

Turning the world into data

Introduction

When did Harold Shipman's patients die?

WhatShare of deaths at each hour of the day. Red = patients of the GP Harold Shipman. Navy = patients of other local GPs.

So whatOther GPs' patients died at any hour. Shipman's died mostly between 1pm and 5pm, the time of his home visits. A simple plot of the right data shows the pattern that let him kill more than 200 people over 20 years.

Values read from the book's figure (Shipman Inquiry).

The problem-solving cycle: PPDAC

WhatThe five stages the book uses for every question. Click a stage to see how it worked for the Shipman inquiry.

So whatStatistics is more than the Analysis step. Most mistakes happen in the Problem, Plan and Data steps, before any formula is used.

1

Getting things in proportion: categorical data and percentages

Learning from data

Same 13 hospitals, three different stories

WhatChildren's heart surgery in UK and Irish hospitals, 2012 to 2015: 12,933 operations and 263 deaths. Change how the same numbers are shown.

So what"98% survive" sounds safe. "2 in 100 die" sounds less safe. An axis that starts at 86% makes small gaps look huge. The framing and the axis change the feeling, not the data.

Table 1.1 of the book. Sorted by number of operations.

Bacon: an 18% higher risk is 1 more person in 100

What100 people who do not eat bacon every day and 100 who eat a bacon sandwich every day. Red = gets bowel cancer in their lifetime.

So whatThe relative risk is 7/6 = 1.18, so "risk up 18%". The absolute change is 1 extra case per 100 people. About 100 people must eat bacon daily for one extra case.

Odds ratios mislead when events are common

WhatBacon (6 vs 7 in 100) and statin muscle pain (85% vs 87%) give the same odds ratio of 1.18. Bars = the relative risk.

So whatFor bacon the odds ratio is close to the relative risk. For statins the real increase is only 2%, but a newspaper reported the 1.18 as "up to 20 per cent". Always ask for the absolute risks.

"99% of young Londoners do not commit serious youth violence"

WhatA 2011 London Underground poster. Each square = 10,000 young people aged 15 to 25 (about 1 million in total).

So whatFlip the frame and turn the percent into people: 1% is 10,000 seriously violent young people. Same fact, opposite feeling.

Bristol, 1991 to 1995: 62 deaths where 32 were expected

WhatDeaths after heart surgery in children under 1 at the Bristol Royal Infirmary, 505 operations, compared with the national rate.

So whatAbout 30 more children died than expected. Counting outcomes and comparing with a fair standard is how the problem was found.

2

Summarizing and communicating numbers. Lots of numbers

Learning from data

915 guesses of the jelly beans in a jar

WhatEach dot is one guess (log scale). The true count was 1,616. Lines mark the mean, median and the true count.

So whatThe guesses are very skewed: one person said 31,337. The mean (2,408) is pulled far up by these values. The median (1,775) is closer to the truth and beat about 90% of the individual guesses. This is the wisdom of crowds.

Dots are simulated to match the book's summary: median 1,775, quartiles 1,109 and 2,599, range 219 to 31,337, mode 10,000.

Lifetime sexual partners: mean vs median

WhatNatsal-3 survey, people aged 35 to 44. Mean and median reported number of opposite-sex partners.

So whatA few people report very large numbers, so the mean is far above the median. For skewed data, report the median and the spread, not only the average.

Busier hospitals, better survival?

WhatUnder-1 heart surgery, 1991 to 1995. Number of operations and survival rate for 12 hospitals. Toggle Bristol.

So whatPearson correlation 0.59, Spearman rank correlation 0.85: bigger hospitals did better. By 2012 to 2015 the link had gone (Pearson 0.17).

Values read from the book's figure.

Women's life events, by birth cohort

WhatMedian age of British women at first sex, first living with a partner, and first child, by the years they were born (Natsal).

So whatFirst sex moved earlier, from 20 to 17. First child moved later, from 24 to 29. The gap between the two grew from 4 years to 12.

3

Why are we looking at data anyway? Populations and measurement

Learning from data

How you ask decides what you hear

WhatThe same question asked two ways. Support for votes at 16 when called "giving the right to vote" vs "reducing the voting age".

So whatSupport was 52% with one wording and 37% with the other. Majority support became majority opposition.

The 1969 draft lottery was not random

WhatEach square is one birthday in January or December. Red = men born on that date were drafted to Vietnam.

So what26 of 31 December birthdays were drafted, but only 14 of 31 in January. The 366 capsules went into the box month by month and were not mixed, and people drew from the top.

Which dates in each month were drafted is not shown in the book; squares are filled in order.

Is a 2,910 g baby small?

WhatBirth weights of 1,096,277 US babies (non-Hispanic white, born at 39 to 40 weeks, 2013) follow a normal curve: mean 3,480 g, SD 462 g. Move the weight.

So what2,910 g is 1.2 standard deviations below the mean, the 11th percentile. Low but normal. The curve predicts 1.7% under 2,500 g; the real share was 1.3%.

Two measures of crime, two directions

WhatChange in crime in England and Wales from 2016 to 2017 by the Crime Survey (about 38,000 households) and by police records.

So whatThe survey said crime fell 9%. Police records said it rose 13%. Recording practice changed: police-recorded sexual offences nearly doubled from 64,000 (2014) to 121,000 (2017).

Online volunteers are not the population

WhatShare of young people who say they often feel lonely: in official surveys vs a BBC online survey that people chose to answer.

So whatPeople who join a survey about loneliness are more likely to be lonely. A big self-selected sample is still a biased sample.

4

What causes what?

Learning from data

The Heart Protection Study: 20,536 people, randomized

WhatShare of people with each event over 5 years. Navy = given a dummy pill, red = given a statin. Labels = relative reduction with its 95% interval.

So whatRandom allocation makes the groups alike in everything except the pill, so the gap is caused by the statin. Heart attacks fell from 11.8% to 8.7%: about 30 people take a statin for 5 years to prevent one.

Intention to treat: 18% of the statin group stopped and 32% of the placebo group started statins. The true effect of taking the drug is about 50% larger.

Simpson's paradox: Cambridge admissions, 1996

WhatAcceptance rate for women and men applying to five subjects. Circle size = number of applicants. Switch to the combined view.

So whatIn every subject, women had the same or higher acceptance rate than men. Combined, women did worse: 23% vs 24%. Women mostly applied to the most competitive subjects (medicine and veterinary science). A hidden third factor can reverse a comparison.

A relative risk above 2 means "more likely than not"

What1,000 people exposed to something. Navy = 10 cases expected anyway. Red = 15 extra cases with the exposure (relative risk 2.5).

So whatCourts use this rule: if the risk more than doubles, more than half the cases among exposed people were caused by the exposure, so any one case is "more likely than not" caused by it.

Bradford Hill: when does association suggest causation?

WhatThe criteria the book lists for judging causation without a trial, in three groups: direct, mechanistic and parallel evidence.

So whatNo single test proves cause; each item adds weight. Red ticks = the book's example: mouth ulcers after rubbing aspirin on the gum meet 5 of 7, enough to call it a real side effect.

5

Modelling relationships using regression

Learning from data

Galton's families: regression to the mean

WhatReal data from Galton's 1886 survey: each dot is one adult child and one parent. Red = least-squares line. Dashed = "same height as parent".

So whatThe red line is flatter than the dashed one. Tall parents have tall children, but less tall. Galton called this "regression towards mediocrity". Hover over the dots.

HistData GaltonFamilies: 934 children of 205 families. The book's version has 465 sons and 433 daughters.

Pick the worst sites, then wait a year

What200 road sites with the same true accident rate. Year 1 counts are random. Pick the worst sites (red), do nothing, and look at year 2.

So whatThe worst sites improve with no treatment at all. This is why about two thirds of the apparent benefit of speed cameras was regression to the mean.

Simulated: every site has a true rate of 4 accidents a year (Poisson counts).

Multiple regression: both parents count

WhatInches of extra child height for each inch a parent is above average, from a model that uses both parents at once (Galton's data, the book's Table 5.3).

So whatFathers matter a little more than mothers for both sons and daughters. Each coefficient is below 0.5, so children's heights still regress toward the mean.

6

Algorithms, analytics and prediction

Learning from data

Who survived the Titanic?

WhatSurvival rate by group in the training set of 897 passengers. Line = the overall rate of 39%.

So whatSex, class, title, fare and family size each predict survival. The title "Mr" (16%) separates people almost as well as any algorithm.

Values read from the book's figure.

A classification tree: follow a passenger

WhatThree yes/no questions put each passenger in one of 5 groups. Bar = share of the group that survived. Pick a passenger.

So whatFrancis Somerton, "Mr" in third class, falls in a group where 16% survived. The tree's accuracy on new data is 81%. Simple rules work well.

ROC curve: trading sensitivity for specificity

WhatShare of survivors found (sensitivity) against share of non-survivors correctly rejected (specificity) as the threshold changes. Solid = test set, dashed = training set.

So whatA 70% threshold finds only half the survivors but almost never makes a false claim. Area under the curve on new data is 0.82. The diagonal is a coin flip.

Values read from the book's figure.

Ten algorithms, three scores

WhatPerformance on the 412 test passengers. Pick the score. Red = the best.

So what"Women survive, men don't" gets 79% accuracy, almost as good as a neural network, but has no skill at ranking. The random forest ranks best, but the simple tree has the best probabilities (Brier score). No algorithm wins on all three, and the margins are within chance.

The Brier score: how good are probability forecasts?

WhatA forecaster's chance of rain each day (red) against what happened. Navy = a lazy forecast of 20% every day from climate records. Bar height = squared error.

So whatThe forecaster's average squared error is 0.11, against 0.28 for climate alone: a 61% skill score. Real next-day rain forecasts score about 0.4.

Predict 2.1: what each breast cancer treatment adds

What100 women aged 65 after surgery for a 2 cm grade 2 tumour. Number alive after 10 years with each added treatment.

So whatSurgery alone: 64 of 100. Adding hormone therapy, chemotherapy and trastuzumab raises it to 70, 76 and 79. 13 would die of other causes anyway. An open algorithm like this lets patients see the trade-offs for themselves.

7

How sure can we be about what is going on? Estimates and intervals

Uncertainty and inference

The bootstrap: resample your own sample

WhatTop: one sample of men's reported lifetime partners. Each click draws a new sample of the same size from it, with replacement, and adds its mean to the bottom chart, which starts with 1,000 resamples.

So whatThe data are very skewed, but the resampled means form a symmetric bell. The middle 95% of them is the uncertainty interval. Bigger samples give narrower bells.

The 796 values are rebuilt from the book's Natsal-3 histogram (men aged 35 to 44) with a tail above 50 so that the mean is 14.9.

More data, narrower intervals

WhatMean number of partners and the 95% bootstrap interval for samples of 10, 50, 200 and all 796 men (the book's Table 7.2).

So whatWith 10 men the mean could be anywhere from 10 to 35. With 796 it is 13.4 to 16.6. The width shrinks with the square root of the sample size.

Unemployment "fell by 3,000"

WhatUK change in unemployment over three months to Nov 2017, with its margin of error of ±77,000 from a survey of about 100,000 people.

So whatThe interval runs from a fall of 80,000 to a rise of 74,000. We cannot say whether unemployment went up or down.

Bootstrapping a regression line

WhatGalton's daughters and mothers. Each grey line is the least-squares fit to one bootstrap resample of the pairs.

So whatThe lines barely move because the sample is large. The book's 95% interval for the slope is 0.22 to 0.44 around 0.33.

8

Probability: the language of uncertainty and variability

Uncertainty and inference

The Chevalier de Méré's two games

WhatGame 1: win if a six appears in 4 throws of one die. Game 2: win if a double six appears in 24 throws of two dice. Lines = running share of games won.

So whatEarly on Game 2 can look better. After a few hundred games Game 1 pulls ahead and settles near 51.8% against 49.1%. Pascal and Fermat worked out why in 1654, and started probability theory.

Expected frequencies: a "90% accurate" scan

What1,000 women screened by mammography. Move the share who have cancer and the accuracy of the test.

So whatWith 1% prevalence and 90% accuracy, 108 women test positive but only 9 have cancer: 8%. The chance of a positive test given cancer is not the chance of cancer given a positive test.

Homicides per day follow a Poisson distribution

WhatDays with 0, 1, 2 and more homicide incidents in England and Wales, Apr 2014 to Mar 2016 (1,095 days, 1.41 a day). Red = observed, navy = expected from a Poisson model.

So whatEach death has its own story, yet the counts act as if made by a known random process. The model gives the chance of 7 or more in a day: 0.07%, about once every four years.

9

Putting probability and statistics together

Uncertainty and inference

A "threefold variation" in bowel cancer deaths

WhatYearly death rate against population for 380 UK districts. Dashed lines: where 95% and 99.8% of districts should fall if every district had the same risk (17.6 per 100,000). Click to simulate a new year.

So whatSmall districts swing a lot by chance alone. Rates from 9 to 31 per 100,000 are what equal risk produces. Only Glasgow City is outside the funnel.

Districts simulated with equal risk and population sizes like the book's figure. Glasgow City (31 per 100,000) is the real outlier.

The binomial: share of left-handers in a sample

WhatProbability of each observed share of left-handers when 20% of the population is left-handed. Pick the sample size.

So whatSmall samples can show almost anything. As the sample grows the spread narrows and the shape becomes a normal curve. This is the Central Limit Theorem.

Margin of error: 100 / √n

WhatThe largest 95% margin of error on a survey percentage for each sample size. Red dashed = Spiegelhalter's rule for polls: double it.

So whatA poll of 1,000 has ±3% at most, in theory. 2017 UK election polls varied far more than that, because of who answered, not chance.

Homicides in England and Wales, with 95% intervals

WhatYearly counts (April to March). Whiskers = 95% confidence interval for the underlying rate, using a Poisson model: count ± 1.96 × √count.

So whatThe count is exact, but the underlying risk is uncertain. The rise from 497 to 557 has an interval of −4 to +124 for the change: right on the edge of a real increase.

Values read from the book's figure.

10

Answering questions and claiming discoveries

Uncertainty and inference

Arbuthnot, 1710: the first significance test

WhatBoys christened per 100 girls in London for each of 82 years, 1629 to 1710. Dashed = equal numbers.

So whatMore boys every year. If boys and girls were equally likely, this would be like 82 heads in a row: a chance of 1 in 2⁸², a number with 24 zeros after the decimal point.

Real data: HistData Arbuthnot.

A permutation test: do women fold arms differently?

What54 students: 9 of 14 women and 23 of 40 men put their right arm on top, a 7-point gap. Shuffle the arm labels at random many times and record the gap each time.

So whatGaps this big in favour of women happen 45% of the time by chance (red). Doubled for either direction, the P-value is about 0.9. No evidence of a difference.

Run enough tests and something is "significant"

WhatChance of at least one result with P < 0.05 when nothing is real, for a number of independent tests. Move the number.

So what10 tests give a 40% chance of a false discovery. A dead salmon scanned at 8,064 brain sites had 16 "responding". The Bonferroni fix: use 0.05 ÷ number of tests.

Could Harold Shipman have been caught earlier?

WhatDeath certificates signed by Shipman for patients over 65, minus the number expected. Switch to the sequential test (SPRT), which looks for a doubling of the death rate. Grey bands = alarm thresholds.

So whatHis excess ended at 174 women and 49 men, close to the confirmed victims. The sequential test would have crossed the strictest threshold in 1984 or 1985. About 175 lives could have been saved.

Values read from the book's two figures.

Why a third of "discoveries" can be false

What1,000 studies. Move the share of studies testing a real effect, the power, and the P-value threshold.

So whatWith 10% real effects, 80% power and P < 0.05, there are 125 "discoveries" and 45 of them are false: 36%. With P < 0.005 it drops to about 5%.

11

Learning from experience the Bayesian way

Uncertainty and inference

Is this skeleton Richard III?

WhatOdds that the first skeleton dug up in a Leicester car park is Richard III. Start with sceptical odds of 1 to 400, then multiply by the likelihood ratio of each piece of evidence (log scale).

So whatNo single finding is convincing, but together they multiply to about 6.5 million. The final odds are about 16,000 to 1 that it is the king. This is Bayes' theorem: posterior odds = prior odds × likelihood ratio.

The book's Table 11.1 multiplies to 6.5 million; its text uses 6.7 million and gets about 17,000 to 1. British courts accept single likelihood ratios but do not let experts multiply them.

A "95% accurate" doping test

What1,000 athletes tested. Red = dopers who test positive, navy = clean athletes who test positive. Pick how common doping is.

So whatIf 1 in 50 dope, 68 test positive and only 19 of them dope: 28%. The test's likelihood ratio is 19, but the answer depends on the prior.

Would the Archbishop of Canterbury cheat at poker?

WhatHe deals himself a royal flush: 72,000 times more likely if he cheats. Move your prior odds that he is a cheat.

So whatAt 1 in a million, the chance he cheated is only 7%. For a stranger in a pub with a 1 in 100 prior, it is 99.9%. The same evidence means different things.

Bayes' billiard table

WhatA white ball lands at a hidden spot. Red balls are thrown and you are told only how many land to its left. The curve is your belief about where the white ball is.

So whatWith 2 left and 3 right, the best estimate is (2+1)/(5+2) = 3/7, not 2/5. The prior pulls estimates toward the middle (shrinkage). Each throw narrows the curve.

12

How things go wrong

Doing statistics well

The Reproducibility Project: 100 psychology studies

WhatShare of the original studies and of their larger repeats with a statistically significant result.

So what97% fell to 36%. The repeated effects were about half the original size. Only 23% of pairs were significantly different from each other, so "significant vs not" overstates the failure.

What 2,155 US psychologists admitted

WhatShare who said they had done each questionable research practice (2012 survey).

So whatOnly 2% admitted making up data, but 94% admitted at least one practice that makes false findings more likely.

P-hacking: keep testing until it works

WhatMany studies of an effect that does not exist. Each researcher tests after every 10 subjects and stops as soon as P < 0.05. Lines = the P-value path of each study. Move the number of looks.

So whatOne look gives 5% false positives, as promised. Looking 10 times more than triples it. "Collecting more data after checking significance" was admitted by 58% of psychologists.

Simulated: 200 studies, 10 subjects per look in each of two groups, true difference zero, t-test at each look.

Exaggeration starts in the press office

WhatShare of 462 UK university press releases (2011) with each kind of exaggeration.

So whatMost exaggerations in the news could be traced back to the press release, not to the journalist.

"Binge watching your TV box sets could kill you"

WhatFatal blood clots in the lungs among people watching more than 5 hours of TV a night: relative risk 2.5, and 13 events per 158,000 person-years.

So whatThe absolute rate means you would need to watch 5 hours a night for about 12,000 years to expect one event.

13

How we can do statistics better

Doing statistics well

Exit polls: seats predicted at 10pm vs the result

WhatUK general elections. Hollow circle = exit poll prediction (about 200 voters at each of 144 polling stations). Solid = seats won.

So whatUsing the same stations as before and modelling the change in vote (multilevel regression and post-stratification), the predictions were within a few seats. In 2015 they predicted 10 Liberal Democrat seats; the party won 8.

The P-curve: spotting publication bias

WhatDistribution of significant P-values (below 0.05) from many simulated studies. Pick what is behind them.

So whatA real effect gives many very small P-values. No effect gives a flat spread. P-hacking piles values just below 0.05. The shape tells you which literature you are reading.

Simulated: 4,000 two-group studies with 20 per group.

Ten questions to ask about a statistical claim

WhatThe book's checklist in three groups: the numbers, the source and the interpretation. Click a question to tick it off for a claim you are checking.

So what"What am I not being told?" is perhaps the most important question of all.

14

In conclusion

Doing statistics well

Ten simple rules for effective statistical practice

WhatThe rules the book ends with, from a group of senior statisticians, with Spiegelhalter's comments.

So whatNone of the rules is about a formula. Most of good statistics is asking the right question, planning, checking data quality and being honest about uncertainty.

From The Art of Statistics: How to Learn from Data by David Spiegelhalter (Basic Books, 2019). Numbers as reported in the book. Where a value was read from one of the book's charts, or a panel uses simulated data, the panel says so. Real datasets: Galton's family heights and Arbuthnot's christenings (R package HistData). Interactive panels are labelled.