20.5 Outliers and Cleaning Data
AQA A-level Maths Statistics and Mechanics Year 1 (AS) · 7357 · Chapter 20: 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: Ex: 1
- Video: Outliers: Ex: 2
- Video: Box plot: Ex:1
- Video: Representation of Data: Box Plots (Intro1)
- Video: Representation of Data: Box Plots Intro2 (SM Practice OSG)
- Video: Representation of Data: Box Plots example 1
- Video: Representation of Data: 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 AQA A-level Maths SM Year 1 lesson for AQA A-level Mathematics (7357) from OBA School: identifying outliers, deciding what to do with them, and preparing raw data for analysis (AQA 7357: L4). 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 the large data set of cars, often need cleaning before you can use them. Knowing what typical values look like helps you to spot problems. Look for:
- values in the wrong units or format (an engine size of 1.6 in litres among values in cm³, "Petrol" and "petrol" typed differently)
- impossible values (a car with a mass of 13 kg, CO₂ emissions of 1320 g/km)
- missing values, recorded as blanks, 0 or a code such as "n/a"
- values that are inconsistent with other columns (a petrol car with an engine size of 0, a hybrid with CO₂ emissions of 0)
- A; Propulsion Petrol; Engine size (cm³) 1199; Mass (kg) 1165; CO₂ (g/km) 118
- B; Propulsion Diesel; Engine size (cm³) 1995; Mass (kg) 1540; CO₂ (g/km) 1320
- C; Propulsion Electric; Engine size (cm³) 0; Mass (kg) 1610; CO₂ (g/km) 0
- D; Propulsion Petrol; Engine size (cm³) 1.5; Mass (kg) 1290; CO₂ (g/km) 126
- E; Propulsion Diesel; Engine size (cm³) 1968; Mass (kg) n/a; CO₂ (g/km) 141
- F; Propulsion Hybrid; Engine size (cm³) 1798; Mass (kg) 1395; CO₂ (g/km) 0
Worked example: checking rows of the large data set
A and C are fine: an electric car really does have an engine size of 0 and CO₂ emissions of 0.
B: 1320 g/km is about ten times a typical value, so it is almost certainly 132 typed with an extra digit.
D: 1.5 is an engine size in litres, so it should be 1500 cm³. E: the mass is missing.
F: a hybrid has a petrol or diesel engine, so its CO₂ emissions cannot be 0. The 0 is a missing value.
Answer: Correct B (to 132, after checking the source) and D (to 1500). Leave E out of any analysis of mass and F out of any analysis of CO₂, and report that these values are 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 data set of new cars, the mass of one family car is recorded as 13 kg. 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 mass; Remove the whole data set.)
Answer: Treat it as an error: correct it if possible, otherwise remove it
Working: A car cannot have a mass of 13 kg, so it is an error. Check the source (perhaps 1300) or remove it.
Related lessons
- Previous lesson: 20.4 Scatter Diagrams and Correlation
- Next lesson: 21.1 Combining Probabilities
- In this chapter: 20.1 Statistical Diagrams
- In this chapter: 20.2 Standard Deviation
- In this chapter: 20.3 Calculations from Frequency Tables
Continue in the full course
This lesson is section 20.5 of our free AQA 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 20.5 in the free course →