lies, damned lies and statistics - europython 2018...lies, damned lies and statistics...

73
Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018

Upload: others

Post on 28-Mar-2021

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Lies, Damned Liesand Statistics

@MarcoBonzanini

EuroPython 2018 Edinburgh, UK

July 2018

Page 2: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

In the Vatican Citythere are 5.88 popes

per square mile

2

Page 3: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

This talk is about:

• The misuse of statistics in everyday life

• How (not) to lie with statistics

This talk is not about:

• Python

• Advanced Statistical Models

The audience (you!):

• Good citizens

• An interest in statistical literacy(without an advanced Math degree?)

3

Page 4: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

LIES, DAMNED LIES AND CORRELATION

Page 5: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Correlation

5

Page 6: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Correlation

• Informal: a connection between two things

• Measure the strength of the association between two variables

6

Page 7: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Linear Correlation

7

Page 8: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Linear Correlation

8

Positive Negative

x x

yy

Page 9: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Correlation Example

9

Page 10: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Correlation Example

10

Temperature

Ice CreamSales ($$$)

Page 11: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

“Correlation does not imply

causation”

11

Page 12: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

12

Deaths bydrowning

Ice CreamSales ($$$)

Page 13: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

13

Lurking Variable

Page 14: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

14

Temperature

Ice CreamSales ($$$)

Temperature

Deaths bydrowning

Lurking Variable

Page 15: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

More Lurking Variables

15

Page 16: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

More Lurking Variables

16

Damagecausedby fire

Firefightersdeployed

🔥

Page 17: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

More Lurking Variables

17

Damagecausedby fire

Firefightersdeployed

Fire severity?

Page 18: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Correlation and causation

18

Page 19: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Correlation and causation

• A causes B, or B causes A

• A and B both cause C

• C causes A and B

• A causes C, and C causes B

• No connection between A and B

19

Page 20: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

20

http://www.tylervigen.com/spurious-correlations

Page 21: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

21

http://www.tylervigen.com/spurious-correlations

Page 22: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

22

https://www.buzzfeed.com/kjh2110/the-10-most-bizarre-correlations

Page 23: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

23

https://www.buzzfeed.com/kjh2110/the-10-most-bizarre-correlations

Page 24: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

24

http://www.nejm.org/doi/full/10.1056/NEJMon1211064

Page 25: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

LIES, DAMNED LIES,SLICING AND DICING

YOUR DATA

Page 26: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Simpson’sParadox

26

Page 27: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

27

University of California, Berkeley Graduate school admissions in 1973

https://en.wikipedia.org/wiki/Simpson%27s_paradox

Page 28: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

28

University of California, Berkeley Graduate school admissions in 1973

https://en.wikipedia.org/wiki/Simpson%27s_paradox

Gender bias?

Page 29: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

29

University of California, Berkeley Graduate school admissions in 1973

https://en.wikipedia.org/wiki/Simpson%27s_paradox

Page 30: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

30

University of California, Berkeley Graduate school admissions in 1973

https://en.wikipedia.org/wiki/Simpson%27s_paradox

Page 31: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

31

University of California, Berkeley Graduate school admissions in 1973

https://en.wikipedia.org/wiki/Simpson%27s_paradox

Page 32: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

32

University of California, Berkeley Graduate school admissions in 1973

https://en.wikipedia.org/wiki/Simpson%27s_paradox

Page 33: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

LIES, DAMNED LIES AND SAMPLING BIAS

Page 34: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Sampling

34

Page 35: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Sampling

35

• A selection of a subset of individuals

• Purpose: estimate about the whole population

• Hello Big Data!

Page 36: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Bias

36

Page 37: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Bias

37

• Prejudice? Intuition?

• Cultural context?

• In science: a systematic error

Page 38: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

“Dewey defeats Truman”

38

Page 39: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

“Dewey defeats Truman”

39

https://en.wikipedia.org/wiki/Dewey_Defeats_Truman

Page 40: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

“Dewey defeats Truman”

40

https://en.wikipedia.org/wiki/Dewey_Defeats_Truman

• The Chicago Tribune printed the wrong headline on election night

• The editor trusted the results of the phone survey

• … in 1948, a sample of phone users was not representative of the general population

Page 41: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Survivorship Bias

41

Page 42: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Survivorship Bias

• Bill Gates, Steve Jobs, Mark Zuckerberg are all college drop-outs

• … should you quit studying?

42

Page 43: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

LIES, DAMNED LIES AND DATAVIZ

Page 44: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

“A picture is worth a thousand words”

44

Page 45: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

45

https://en.wikipedia.org/wiki/Anscombe%27s_quartet

Page 46: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

46

https://venngage.com/blog/misleading-graphs/

Page 47: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

47

https://venngage.com/blog/misleading-graphs/

Page 48: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

48

https://venngage.com/blog/misleading-graphs/

Page 49: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

49

http://www.businessinsider.com/gun-deaths-in-florida-increased-with-stand-your-ground-2014-2?IR=T

Page 50: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

50

http://www.businessinsider.com/gun-deaths-in-florida-increased-with-stand-your-ground-2014-2?IR=T

Page 51: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

51

http://www.businessinsider.com/gun-deaths-in-florida-increased-with-stand-your-ground-2014-2?IR=T

Page 52: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

52

https://www.raiplay.it/video/2016/04/Agor224-del-08042016-4d84cebb-472c-442c-82e0-df25c7e4d0ce.html

Page 53: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

53

https://www.theguardian.com/news/datablog/2014/may/12/lies-election-leaflets-five-tricks-european-elections

Page 54: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

54

https://www.theguardian.com/news/datablog/2014/may/12/lies-election-leaflets-five-tricks-european-elections

Page 55: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

55

https://www.theguardian.com/news/datablog/2014/may/12/lies-election-leaflets-five-tricks-european-elections

Page 56: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

56

https://www.theguardian.com/news/datablog/2014/may/12/lies-election-leaflets-five-tricks-european-elections

Page 57: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

57

https://www.theguardian.com/news/datablog/2014/may/12/lies-election-leaflets-five-tricks-european-elections

Page 58: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

58

https://www.theguardian.com/news/datablog/2014/may/12/lies-election-leaflets-five-tricks-european-elections

Page 59: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

LIES, DAMNED LIES AND SIGNIFICANCE

Page 60: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Significant = Important

60

?

Page 61: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Statistically Significant Results

61

Page 62: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Statistically Significant Results

62

• We are quite sure they are reliable (not by chance)

• Maybe they’re not “big”

• Maybe they’re not important

• Maybe they’re not useful for decision making

Page 63: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

p-values

63

Page 64: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

64

https://en.wikipedia.org/wiki/Misunderstandings_of_p-values

Page 65: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

p-values

• Probability of observing our results (or more extreme) when the null hypothesis is true

• Probability, not certainty

• Often p < 0.05 (arbitrary)

• Can we afford to be fooled by randomness every 1 time out of 20?

65

Page 66: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Data dredging

66

Page 67: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

67

Page 68: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

Data dredging• a.k.a. Data fishing or p-hacking

• Convention: formulate hypothesis, collect data, prove/disprove hypothesis

• Data dredging: look for patterns until something statistically significant comes up

• Looking for patterns is ok Testing the hypothesis on the same data set is not

68

Page 69: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

SUMMARY

Page 70: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

— Dr. House

“Everybody lies”

70

Page 71: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

71

• Good Science ™ vs. Big headlines

• Nobody is immune

• Ask questions: What is the context? Who’s paying? What’s missing?

• … “so what?”

Page 72: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes

THANK YOU

@MarcoBonzanini speakerdeck.com/marcobonzanini

GitHub.com/bonzanini

marcobonzanini.com

Page 73: Lies, Damned Lies and Statistics - EuroPython 2018...Lies, Damned Lies and Statistics @MarcoBonzanini EuroPython 2018 Edinburgh, UK July 2018 In the Vatican City there are 5.88 popes