01 / 21

Outliers &
Data Cleaning

Learn to identify outliers in biostatistical data, understand their impact on analysis, and apply principled data cleaning strategies.

Biostatistics

What Is an Outlier?

An outlier is a data point that differs significantly from other observations. In biostatistics, an outlier might be a patient's lab value that falls far outside the expected range: it could signal a measurement error, a rare condition, or a data entry mistake.

Why Outliers Matter in Biostatistics

Distort Statistics
A single extreme value can shift the mean and inflate the standard deviation, misrepresenting the population.
Bias Models
Regression lines and predictive models are pulled toward outliers, reducing accuracy for the majority of data.
Reveal Insights
Some outliers are genuine discoveries: a rare genetic variant, an unexpected drug response, or a novel disease marker.

How One Outlier Shifts the Mean

Patient Heart Rate (bpm) 60 80 100 200 Outlier: 200
\( \text{Mean without} = 80 \)
\( \text{Mean with} = 92 \)
Heart rate data (n = 10) One outlier shifts the mean by +12 bpm

The IQR Method for Detecting Outliers

The Interquartile Range (IQR) method is one of the most common techniques. It uses the spread of the middle 50% of data to define boundaries:

The Z-Score Method

The Z-score measures how many standard deviations a point is from the mean. It assumes the data is approximately normally distributed.

\( \bar{x} - 3s \)
\( \bar{x} - 2s \)
\( \bar{x} \)
\( \bar{x} + 2s \)
\( \bar{x} + 3s \)
Outlier zone Outlier zone Z-score distribution

IQR vs Z-Score: Key Distinction

IQR Method Z-Score Method
Assumption None (non-parametric) Approx. normal distribution
Formula Uses fences based on \(1.5 \times \text{IQR}\) \( |z| > 3 \)
Robustness High: resistant to extreme values Low: mean and SD shift with outliers
Best for Skewed data, small samples Large, symmetric datasets
Visualization Box plot (whiskers) Histogram + Z overlay

What Is Data Cleaning?

Data cleaning is the process of detecting and correcting (or removing) corrupt, inaccurate, or irrelevant records from a dataset. In biostatistics, this includes handling outliers, missing values, duplicate entries, and measurement errors.

Errors
Typos, instrument malfunction, wrong units (kg vs. lbs)
Missing Data
Blank fields, "N/A" entries, patients lost to follow-up
Duplicates
Same patient entered twice, merged records from multiple systems

Types of Outliers

Error Outlier
Caused by a mistake: wrong decimal, faulty sensor, swapped patient ID. Should be corrected or removed.
Natural Outlier
A genuine extreme value: a very tall person, a rare genetic mutation. Should be kept and noted.
Influential Outlier
Disproportionately affects results (high leverage in regression). Must be tested with sensitivity analysis.

Data Cleaning Step by Step

1
Inspect visually. Plot your data with histograms, box plots, and scatter plots to spot suspicious values immediately.
2
Apply detection rules. Use the IQR method or Z-scores to flag potential outliers quantitatively.
3
Investigate each flagged point. Check source records: was the value entered correctly? Is the measurement plausible?
4
Decide and document. Correct errors, keep genuine values, and document every decision in your analysis log.
5
Run sensitivity analysis. Analyze results with and without the outlier. If conclusions change, report both.

Example 1: IQR Method

A clinical study records the white blood cell counts (\( \times 10^3 / \mu L \)) of 12 patients:

1
Find quartiles: \( Q_1 = 5.9 \), \( Q_3 = 7.95 \)
2
Compute IQR: \( \text{IQR} = 7.95 - 5.9 = 2.05 \)
3
Fences: Lower = \( 5.9 - 1.5(2.05) = 2.825 \), Upper = \( 7.95 + 1.5(2.05) = 11.025 \)
4
Result: 18.4 exceeds the upper fence of 11.025 and is flagged as an outlier.

Example 1: Box Plot Visualization

WBC Count (x10³/µL) 2 4 6 8 10 12 16 18 Fence: 11.03 18.4 Outlier Min
\( Q_1 \)
Median
\( Q_3 \)
Max* WBC Count Box Plot *Max non-outlier value

Example 2: Z-Score Detection

Systolic blood pressure readings (mmHg) for 8 patients:
118, 122, 125, 119, 130, 121, 127, 210

1
Mean: \( \bar{x} = \frac{118+122+125+119+130+121+127+210}{8} = 134.0 \)
2
Standard deviation: \( s \approx 30.97 \)
3
Z-score for 210: \( z = \frac{210 - 134.0}{30.97} \approx 2.45 \)
4
Result: \( |z| = 2.45 \), which does not exceed the \( |z| > 3 \) threshold. Despite being clearly anomalous, the point is not flagged by the strict Z-score rule — a textbook example of the masking effect.

Example 3: Decision Framework

A drug trial records patient weight (kg). One participant is listed as 8.2 kg while all others range from 55-95 kg. What should you do?

Detect: 8.2 kg flagged Investigate source records Decimal error found Correct to 82.0 kg No record available Exclude + document Always document your decision in the analysis log

Common Mistakes

✕ Auto-Deleting Outliers
Removing any point beyond the IQR fences without investigation. Some outliers are real and important (e.g., adverse drug events).
✕ Ignoring Outliers Entirely
Assuming all data is clean. Undetected errors can invalidate your entire analysis and lead to wrong clinical conclusions.
✕ Using Z-Scores on Skewed Data
The Z-score method assumes normality. Applying it to right-skewed biomedical data (like hospital costs) misses real outliers.

Summary: Detection & Action

Scenario Detection Action
Data entry error IQR or Z-score Correct from source
Instrument malfunction Visual inspection Exclude + document
Natural extreme IQR or Z-score Keep + flag
Influential point Cook's distance, leverage Sensitivity analysis
Unknown cause Multiple methods Analyze with and without

Question 1 of 5

A dataset has \( Q_1 = 20 \), \( Q_3 = 40 \), and \( \text{IQR} = 20 \). Using the 1.5 IQR rule, what is the upper fence?

Question 2 of 5

Which outlier detection method is most appropriate for a small, right-skewed dataset?

Question 3 of 5

A patient's recorded weight in a clinical trial is \( 7.5 \text{ kg} \), while all other patients range from \( 60-100 \text{ kg} \). After investigation, no source record can be found. What is the best course of action?

Question 4 of 5

A key weakness of the Z-score method for outlier detection is that:

Question 5 of 5

In a clinical trial, one patient shows an unusually high liver enzyme value. The value is confirmed as accurate by the lab. What should the researcher do?