Hello again. In our last session, we moved from the theory of sample size to the practicalities of data collection, learning how to adjust for non-response to ensure you gather enough usable data. Now that we have our raw dataset, the next critical step in any analysis is quality control. Even with a perfect data collection plan, errors and anomalies can find their way into your data.
This lesson focuses on a crucial aspect of data cleaning: detecting outliers. Outliers are extreme data points that can significantly distort your summary statistics and model results. As you've noted, dealing with them is a major part of a statistician's work. We will focus on the mathematical application of two of the most common methods for identifying them: the z-score method and the interquartile range (IQR) method.
What Are Outliers and Why Do They Matter?
Before we jump into calculations, let's formalize our understanding of outliers. They are data points that lie an abnormal distance from other values in a dataset. An outlier could be a genuine, albeit rare, observation (a "true outlier"), or it could be the result of a mistake, such as a data entry error or equipment malfunction.
Regardless of their origin, outliers can have a disproportionate influence on your analysis. For instance, a single extreme value can dramatically shift the mean and inflate the standard deviation, potentially leading you to incorrect conclusions about the data's central tendency and spread.
The following resource provides a solid overview of what outliers are and introduces the two numerical methods we will be using today.
How to Find Outliers | 4 Ways with Examples & Explanation
This article from Scribbr gives a clear, non-technical introduction to outliers and the methods for detecting them. It will set the stage for our detailed calculations.
Please read the introductory section What are outliers? to solidify the concept. Then, in the section "Four ways of calculating outliers," review the descriptions for Statistical outlier detection (the z-score method) and Using the interquartile range (the IQR method). Pay close attention to the rule of thumb for z-scores and the general principle of using "fences" for the IQR method.
Now, let's apply these methods through hand-calculation, starting with the z-score approach.
Method 1: The Z-Score Method
The z-score method quantifies how many standard deviations a data point is from the sample mean. It's a quick way to flag values that are unusual under the assumption that the data are approximately normally distributed.
The formula for a sample z-score is:
Where:
- is the individual data point.
- is the sample mean.
- is the sample standard deviation.
A common rule of thumb is that any data point with a z-score greater than +3 or less than -3 is considered a potential outlier.
Numerical Example 1: Bra-Fitting Business
Scenario: You have collected under-bust measurements (band size, in inches) from a sample of 11 new clients. Your goal is to check for data entry errors before calculating summary statistics for your client records.
Data: 34, 36, 34, 38, 36, 32, 36, 34, 48, 38, 36
Calculation:
-
Calculate the sample mean ():
-
Calculate the sample standard deviation ():
First, the sum of squared differences from the mean:Now, calculate the sample variance () and standard deviation ():
-
Calculate the z-score for the suspected outlier (48):
Conclusion: The z-score for the measurement of 48 inches is approximately 2.52. This is high, but it does not cross our threshold of |z| > 3. Based on the z-score method alone, this value would not be flagged as an outlier.
Numerical Example 2: Polyandrous Relationship Study
Scenario: You are studying how couples in 10 different polyandrous "vee" relationships divide their time. You measure the number of one-on-one "date nights" the central person had with one of their partners in a month.
Data: 4, 5, 3, 6, 5, 4, 2, 15, 6, 5
Calculation:
-
Calculate the sample mean ():
-
Calculate the sample standard deviation ():
-
Calculate the z-score for the suspected outlier (15):
Conclusion: The z-score for 15 date nights is approximately 2.79. Similar to the first example, this value is unusually high but does not meet the strict |z| > 3 criterion. This highlights a potential weakness of the z-score method: the mean and standard deviation are themselves influenced by the outlier, which can reduce the resulting z-score.
Method 2: The Interquartile Range (IQR) Method
The IQR method is a more robust alternative that is resistant to the influence of extreme values. It defines outliers based on their position relative to the quartiles of the data, rather than the mean.
The procedure is as follows:
- Find the first quartile (Q1), which is the 25th percentile.
- Find the third quartile (Q3), which is the 75th percentile.
- Calculate the Interquartile Range: . This range contains the middle 50% of the data.
- Calculate the "fences" that mark the boundaries for outliers:
- Lower Fence =
- Upper Fence =
- Any data point that falls below the lower fence or above the upper fence is flagged as an outlier.
To see a full example worked out, let's revisit the Scribbr article.
How to Find Outliers | 4 Ways with Examples & Explanation
Now we'll walk through the step-by-step application of the IQR method.
Please read the entire section titled Example: Using the interquartile range to find outliers. Follow each of the six steps to see how the data is sorted, quartiles are identified, and the fences are used to flag the final outlier. Note the use of the "exclusive method" for finding quartiles, where the median is not included in the two halves of the data.
The images below illustrate the key calculations for the IQR and the resulting "fences".


Now, let's apply this more robust method to our own scenarios.
Numerical Example 1: Bra-Fitting Business (IQR)
Scenario: We'll use the same band size data as before.
Data: 34, 36, 34, 38, 36, 32, 36, 34, 48, 38, 36
Calculation:
-
Sort the data: 32, 34, 34, 34, 36, 36, 36, 36, 38, 38, 48
-
Find Q1 and Q3:
- The dataset has 11 values. The median is the 6th value, which is 36.
- The lower half of the data (excluding the median) is: 32, 34, 34, 34, 36. So, .
- The upper half of the data (excluding the median) is: 36, 36, 38, 38, 48. So, .
-
Calculate the IQR:
-
Calculate the fences:
- Lower Fence =
- Upper Fence =
-
Identify outliers: The fences are [28, 44]. We check our sorted data:
- The minimum value is 32, which is inside the fences.
- The maximum value is 48, which is above the upper fence.
Conclusion: Using the IQR method, the band size of 48 inches is definitively flagged as an outlier. This contradicts the z-score method and shows how the IQR method's resistance to extreme values makes it more sensitive in this case. A value of 48 is indeed unusual in this context and warrants investigationāit could be a typo for "38".
Numerical Example 2: Polyandrous Relationship Study (IQR)
Scenario: We'll re-examine the date night data with the IQR method.
Data: 4, 5, 3, 6, 5, 4, 2, 15, 6, 5
Calculation:
-
Sort the data: 2, 3, 4, 4, 5, 5, 6, 6, 6, 15 (Note: I've corrected a small error in the original data list to have 10 points) -> Sorted: 2, 3, 4, 4, 5, 5, 6, 6, 6, 15.
Let's re-do this calculation with a clean dataset of 10 points. Data: 2, 3, 4, 4, 5, 5, 6, 6, 7, 15. -
Sort the data: 2, 3, 4, 4, 5, 5, 6, 6, 7, 15
-
Find Q1 and Q3:
- The dataset has 10 values. The median is the average of the 5th and 6th values: (5+5)/2 = 5.
- The lower half is: 2, 3, 4, 4, 5. So, .
- The upper half is: 5, 6, 6, 6, 7, 15. Let's use the 10-point dataset: 5, 6, 6, 7, 15. So, .
-
Calculate the IQR:
-
Calculate the fences:
- Lower Fence =
- Upper Fence =
-
Identify outliers: The fences are [1, 9]. Checking our data:
- The value 15 is above the upper fence.
Conclusion: The IQR method flags 15 date nights as an outlier. Again, this method successfully identified the anomalous point where the z-score method did not. The finding doesn't mean the data is "wrong"āit could be a special month, like a vacation or anniversary. But it does mean the point is mathematically extreme and requires a conscious decision about how to handle it, a topic discussed briefly in the Scribbr article.
How to Find Outliers | 4 Ways with Examples & Explanation
Detecting an outlier is only the first step. The crucial next step is deciding what to do about it.
Please read the section Dealing with outliers. This part moves from pure calculation to statistical judgment. It explains the choice between retaining and removing outliers and emphasizes the importance of justifying your decision.
Summary and Next Steps
In this lesson, you've mastered the practical application of two key methods for outlier detection. You have seen how to perform the calculations by hand and how they can sometimes yield different results, underscoring the importance of understanding the assumptions and properties of each technique.
Key Takeaways:
- Outliers are extreme values that can compromise statistical analyses.
- The z-score method identifies outliers as points typically more than 3 standard deviations from the mean. It is sensitive to the outliers themselves.
- The IQR method identifies outliers as points falling outside "fences" defined by and . It is generally more robust and often preferred for exploratory analysis.
- Detecting an outlier is a mechanical process; deciding to retain, correct, or remove it requires critical thinking and domain expertise.
You now know how to find these problematic data points. But what is their actual, quantifiable effect? In our next lesson, we will directly address this by learning to assess the impact of an outlier on descriptive statistics and, crucially, on the coefficients of a linear regression model.