16.5 Outliers and Cleaning Data
OCR A-level Maths Statistics and Mechanics Year 1 (AS) · H240 · Chapter 16: Working with Data
What is in the full lesson (14 activities)
Every item below opens free in the course.
- Video: Introduction to Outlier
- Video: Outliers: example 1
- Video: Outliers: example 2
- Video: Box plot: example 1
- Video: Box Plots (Intro1)
- Video: Box Plots Intro2
- Video: Box Plots example 1
- Video: Box Plots example 4
- Notes: Lesson notes: Outliers and Cleaning Data
- Interactive lesson: Interactive lesson: Outlier Hunter
- Interactive lesson: Interactive practice: Outliers and Cleaning Data Practice
- Practice questions: Practice questions (8 questions, 12 marks)
- Worksheet: Worksheet: Outliers and Cleaning Data
- Answers: Answers and mark scheme of the Worksheet: Outliers and Cleaning Data
A free OCR A-level Maths SM Year 1 lesson for OCR A Level Mathematics A (H240) from OBA School: identifying outliers, deciding what to do with them, and preparing raw data for analysis (OCR H240: 2.02h, 2.02j). Watch the video, read the explanation and worked examples, then try the revision questions. You can work through the full lesson, with more videos, an interactive lesson, a practice quiz and printable worksheets, in our free online course.
What you will learn
- Identify outliers using the 1.5 × IQR rule or the 2 standard deviation rule
- Draw box plots with outliers marked
- Decide whether an outlier is an error or a genuine value, and describe its effect on summary statistics
- Clean a data set: spot errors, missing values and inconsistent formats, and decide what to do with them
Key words
- Outlier: A value that is unusually far from the rest of the data. A question will tell you which rule to use.
- Fence: A limit beyond which values are outliers, such as Q₃ + 1.5 × IQR.
- Anomaly: A value that does not fit the pattern. It may be an error or a genuine but unusual value.
- Cleaning data: Finding and dealing with errors, missing values and inconsistent formats before analysing data.
- Resistant measure: A statistic, such as the median or IQR, that changes little when an extreme value is added or removed.
Two rules for outliers
Key fact: IQR rule: x is an outlier if x < Q₁ − 1.5 × IQR or x > Q₃ + 1.5 × IQR Standard deviation rule: x is an outlier if it is more than 2σ from the mean, that is outside x̅ ± 2σ
Worked example: the IQR rule
Ten people complete a puzzle. Times (seconds): 21, 24, 25, 27, 28, 30, 31, 33, 35, 58.
Lower half 21, 24, 25, 27, 28 gives Q₁ = 25. Upper half 30, 31, 33, 35, 58 gives Q₃ = 33. IQR = 8.
Fences: 25 − 1.5 × 8 = 13 and 33 + 1.5 × 8 = 45
Answer: 58 is above 45, so 58 is an outlier.
Worked example: the standard deviation rule
Same data: Σ x = 312, Σ x² = 10694, so x̅ = 31.2 and σ² = 1069.4 − 31.2² = 95.96
σ = 9.796. Limits: 31.2 ± 2 × 9.796, that is 11.6 to 50.8
Answer: 58 is above 50.8, so it is an outlier by this rule too.
Box plots with outliers
Mark each outlier with a cross. The whisker then stops at the most extreme value that is not an outlier, here 35 (some people end it at the fence instead; either is accepted if you say which).
Worked example: box plot of the puzzle times
Five values are needed: Q₁ = 25, median = (28 + 30)/2 = 29, Q₃ = 33.
Lower whisker: the smallest value, 21, is above the fence 13, so the whisker goes to 21.
Upper whisker: 58 is an outlier, so the whisker stops at 35, the largest value below 45.
Answer: Box from 25 to 33 with median 29, whiskers to 21 and 35, and a cross at 58.
What to do with an outlier
Never delete an outlier automatically. Ask whether it could be genuine.
- Error (impossible or clearly mistyped, such as an age of 213): correct it if you can, otherwise remove it.
- Genuine (such as a very wet day during a storm): keep it. It is real information, and removing it would bias the results.
Worked example: effect of removing the outlier
Suppose the 58 s time was a stopwatch error and is removed. The remaining nine times give:
x̅ = 254/9 = 28.2, σ² = 7330/9 − (254/9)² = 18.0, σ = 4.24
Median: 29 before (mean of 28 and 30) and 28 after.
Answer: The mean fell by 3 s and the standard deviation more than halved; the median hardly changed.
Key fact: The mean and standard deviation are strongly affected by outliers. The median and IQR are resistant, so use them for data with outliers.
Cleaning data
Real data sets, such as census tables of travel to work for local authorities, often need cleaning before you can use them. Look for:
- values in the wrong units or format (a proportion 0.12 where a percentage is expected, "12%" stored as text)
- impossible values (a percentage over 100, a negative count)
- missing values, recorded as blanks, 0 or a code such as "n/a"
- values that are inconsistent with other columns (a percentage that does not match the counts)
- A; Workers 52 310; Number who cycle 1 046; % who cycle 2.0
- B; Workers 48 900; Number who cycle 2 445; % who cycle 5.0
- C; Workers 61 200; Number who cycle 734; % who cycle 12.0
- D; Workers 39 750; Number who cycle not recorded; % who cycle not recorded
- E; Workers 44 000; Number who cycle 1 320; % who cycle 3.0
- F; Workers 57 600; Number who cycle 6 912; % who cycle 12.0
Worked example: checking a census-style table
Check each percentage against the counts.
A: 1046/52310 × 100 = 2.0 ✓ B: 5.0 ✓ E: 3.0 ✓ F: 6912/57600 × 100 = 12.0 ✓
C: 734/61200 × 100 = 1.2, not 12.0, so one entry is mistyped. D is missing.
Answer: Correct C to 1.2% (the counts agree with each other) or check the source; leave D out of the analysis and report that it is missing.
Common mistakes
- Using 1.5 × IQR as the fence itself instead of adding it to Q₃ (or subtracting it from Q₁).
- Removing an outlier just because it is unusual, even though it is a genuine value.
- Drawing the whisker to the outlier as well as marking the cross.
- Treating a missing value recorded as 0 as a real value of zero.
- Mixing units (cm and m, proportions and percentages) in one calculation.
Revision questions
Try these, then check your answers below each one.
Question 1. A data set has mean 50 and standard deviation 8. Outliers are more than 2 standard deviations from the mean. Is 67 an outlier?
Answer: Yes
Working: 50 + 16 = 66, and 67 > 66, so yes.
Question 2. For the data 5, 8, 9, 10, 11, 12, 14, 30, find the upper fence Q₃ + 1.5 × IQR.
Answer: 19.75
Working: Q₁ = 8.5, Q₃ = 13, IQR = 4.5, upper fence = 13 + 6.75 = 19.75. So 30 is an outlier.
Question 3. In a survey of adults, one recorded age is 210. What should you do? (Choose from: Treat it as an error: correct it if possible, otherwise remove it; Keep it, because outliers should never be removed; Replace it with the mean age; Remove the whole data set.)
Answer: Treat it as an error: correct it if possible, otherwise remove it
Working: An age of 210 is impossible, so it is an error. Check the source (perhaps 21) or remove it.
Related lessons
- Previous lesson: 16.4 Scatter Diagrams and Correlation
- Next lesson: 17.1 Combining Probabilities
- In this chapter: 16.1 A Reminder of Statistical Diagrams
- In this chapter: 16.2 Standard Deviation
- In this chapter: 16.3 Calculations from Frequency Tables
Continue in the full course
This lesson is section 16.5 of our free OCR A-level Maths Statistics and Mechanics Year 1 (AS) course. In the full course you get every video for this section, an animated interactive lesson, a self-marking practice quiz, a printable worksheet with a mark scheme, an end-of-chapter test and your progress saved.
Continue lesson 16.5 in the free course →