Impact of Removing Outliers on Median: Practical Examples and Potential Pitfalls
Outliers are among the most interesting and most frequently misunderstood observations in statistics. A single unusually large or unusually small value can attract attention, influence summary statistics, change visualizations, and sometimes alter the story that a dataset appears to tell. But an important question is often overlooked: What happens when we remove an outlier and recalculate the median?
The answer is more subtle than simply saying that an extreme observation "skews" the data. The median is specifically designed to be resistant to extreme values. Unlike the arithmetic mean, the median does not directly use the magnitude of every observation in its calculation. However, removing observations can still change the median because the number of observations and therefore the location of the middle observation changes.
This article explains that idea from the ground up using practical examples involving household expenses and employee salaries. It also explains quartiles, the interquartile range (IQR), the 1.5 × IQR rule, the mathematical reasoning behind the calculations, command-line examples, Python code, interactive accordions, common mistakes, and the important distinction between detecting an outlier and deciding whether an observation should actually be removed.
Table of Contents
- Why Outliers Matter
- Understanding the Median
- Mean Versus Median
- Understanding Quartiles
- Understanding the Interquartile Range
- The 1.5 × IQR Outlier Rule
- Example 1: Household Monthly Expenses
- Example 2: Annual Salaries
- Why Removing an Outlier Can Change the Median
- Mathematical Explanation
- An Outlier Is Not Automatically an Error
- When Should an Outlier Be Removed?
- When Should an Outlier Be Kept?
- Potential Pitfalls
- Code Example
- CLI Output Example
- Interactive Exploration
- Before-and-After Comparison
- Real-World Applications
- Best Practices
- Frequently Asked Questions
- Conclusion
1. Why Outliers Matter
An outlier is an observation that is unusually distant from the other observations in a dataset. The word "outlier" does not necessarily mean "bad data." It simply describes an observation that is unusual relative to some statistical criterion or the general pattern of the data.
Consider a small collection of monthly household expenses:
200, 220, 240, 250, 260, 5000
The value 5000 is dramatically larger than the other observations. It immediately looks unusual. However, several explanations are possible. Perhaps the household normally spends around $200–$260 per month, and 5000 is a data-entry mistake. Perhaps 5000 represents an annual insurance payment recorded in one month. Perhaps it represents a medical emergency, home repair, tuition payment, relocation cost, or another legitimate exceptional expense.
The statistical procedure can identify 5000 as a potential outlier, but the procedure cannot automatically tell us why the observation is unusual.
This distinction becomes critical when we calculate the median before and after removing the observation. The numbers can change, but the change itself does not tell us whether removal was appropriate.
2. Understanding the Median
The median is a measure of central tendency. It represents the middle position of an ordered dataset.
To calculate a median, first arrange observations from smallest to largest. Then determine which observation occupies the central position.
Odd number of observations
If there are an odd number of observations, there is one exact middle value.
10, 20, 30, 40, 50
There are five observations, so the third observation is the median:
Median = 30
Even number of observations
If there are an even number of observations, there are two central observations. The median is the arithmetic average of those two values.
10, 20, 30, 40, 50, 60
The two middle values are 30 and 40.
Therefore:
Median = (30 + 40) / 2 = 35
This simple rule becomes extremely important when an outlier is removed. Removing just one observation can change an odd-sized dataset into an even-sized dataset, or an even-sized dataset into an odd-sized dataset. Consequently, the definition of the middle position changes.
3. Mean Versus Median
One of the most important reasons to study the median is its resistance to extreme observations. The arithmetic mean incorporates every value and therefore reacts strongly to very large or very small observations.
For example:
10, 20, 30, 40, 50
The mean is:
(10 + 20 + 30 + 40 + 50) / 5 = 30
The median is also 30.
Now replace 50 with 5000:
10, 20, 30, 40, 5000
The mean becomes:
(10 + 20 + 30 + 40 + 5000) / 5 = 1020
The median remains 30.
This example demonstrates why the median is often described as robust to extreme values. The value 5000 is extremely large, but because it remains at the end of the ordered dataset, it does not become the middle observation.
However, robustness does not mean that the median is completely unaffected by data removal. If an observation is deleted, the number of observations changes. This can shift the central position even if the removed value was extremely far away.
4. Understanding Quartiles
To understand the IQR method for identifying potential outliers, we need to understand quartiles.
Quartiles divide an ordered dataset into sections based on position. The most commonly discussed quartiles are:
- Q1: the first quartile, representing the lower quarter of the distribution.
- Q2: the second quartile, which is the median.
- Q3: the third quartile, representing the upper quarter of the distribution.
A useful conceptual interpretation is that approximately 25% of observations lie at or below Q1, approximately 50% lie at or below Q2, and approximately 75% lie at or below Q3, depending on the quartile convention used.
Why quartile conventions matter
Different software packages and statistical texts can use slightly different methods for calculating quartiles, especially for small datasets.
This is important because the IQR depends directly on Q1 and Q3. If two systems calculate quartiles differently, they can occasionally produce different IQR values and therefore different outlier classifications.
For educational examples, it is therefore good practice to explicitly state the quartile method being used.
Expand: Why small datasets need extra care
In a large dataset, minor differences between quartile algorithms may have little practical effect. In a dataset containing only five, six, or seven observations, however, every observation has substantial positional importance. A small change in Q1 or Q3 can alter the calculated IQR.
This means that an analyst working with a small sample should avoid presenting an IQR-based outlier decision as an unquestionable fact. It is better to describe the observation as a potential outlier under the selected method.
5. Understanding the Interquartile Range
The interquartile range, commonly abbreviated as IQR, measures the spread of the middle 50% of a dataset.
Its mathematical definition is:
IQR = Q3 − Q1
Unlike the total range, which uses the minimum and maximum values, the IQR focuses on the central portion of the distribution. This makes it relatively resistant to extreme observations.
Suppose:
Q1 = 220
Q3 = 260
Then:
IQR = 260 − 220 = 40
An IQR of 40 tells us that the middle 50% of the observations span 40 units.
6. The 1.5 × IQR Outlier Rule
A commonly used rule for identifying potential outliers is based on 1.5 times the IQR.
The lower boundary is calculated as:
Lower bound = Q1 − 1.5 × IQR
The upper boundary is:
Upper bound = Q3 + 1.5 × IQR
Any observation below the lower bound or above the upper bound is commonly flagged as a potential outlier.
What does 1.5 × IQR actually mean?
The factor 1.5 is a conventional threshold rather than a universal law of nature. It provides a practical rule for identifying observations that are unusually distant from the central distribution.
For example, if:
Q1 = 220
Q3 = 260
IQR = 40
then:
1.5 × IQR
= 1.5 × 40
= 60
Therefore:
Lower bound = 220 − 60 = 160
Upper bound = 260 + 60 = 320
Any value below 160 or above 320 would be flagged using this rule.
Expand: Potential outlier versus confirmed error
The word "potential" is essential. If a value is above the upper IQR boundary, that does not prove that the value is incorrect. It only indicates that the observation is unusually distant according to the selected statistical rule.
A responsible analyst should investigate the observation before deleting it. Check the original source, units, timestamps, measurement process, business context, and whether the observation belongs to the same population as the other observations.
7. Practical Example 1: Household Monthly Expenses
Let us examine a small dataset representing monthly expenses for six households.
200, 220, 240, 250, 260, 5000
The value 5000 immediately looks unusual. However, we will not remove it simply because it looks unusual. Instead, we will follow a structured statistical process.
Step 1: Sort the data
The data is already sorted:
200, 220, 240, 250, 260, 5000
Step 2: Count the observations
There are six observations.
Because six is even, the median is the average of the third and fourth observations.
The third observation is 240 and the fourth observation is 250.
Therefore:
Median = (240 + 250) / 2
= 490 / 2
= 245
So the original median household expense is $245.
Step 3: Calculate Q1
For this example, we use the common median-of-halves approach. The lower half is:
200, 220, 240
The middle value of the lower half is 220.
Q1 = 220
Step 4: Calculate Q3
The upper half is:
250, 260, 5000
The middle value is 260.
Q3 = 260
Step 5: Calculate the IQR
IQR = Q3 − Q1
= 260 − 220
= 40
Step 6: Calculate the bounds
Lower bound = Q1 − 1.5 × IQR
= 220 − 1.5 × 40
= 220 − 60
= 160
Upper bound = Q3 + 1.5 × IQR
= 260 + 1.5 × 40
= 260 + 60
= 320
The upper bound is 320.
Since 5000 is greater than 320, it is flagged as a potential upper outlier.
Step 7: Remove the observation for analytical demonstration
If investigation confirms that 5000 should be excluded from the particular analysis, the remaining observations are:
200, 220, 240, 250, 260
Step 8: Recalculate the median
There are now five observations, so the median is the third observation.
200, 220, [240], 250, 260 Therefore:
New median = 240
Before and after
| Dataset | Number of observations | Median |
|---|---|---|
| Original data | 6 | 245 |
| After removing 5000 | 5 | 240 |
8. Practical Example 2: Annual Salaries in a Small Company
Consider annual salaries, expressed in thousands of dollars:
50, 52, 55, 60, 62, 65, 500 The value 500 represents a salary of $500,000 while the other salaries range from $50,000 to $65,000. It is clearly unusual in this particular dataset, but we still need to investigate before deciding whether it should be removed.
Step 1: Calculate the original median
There are seven observations. Seven is odd, so the median is the fourth observation.
50, 52, 55, [60], 62, 65, 500 Therefore:
Original median = 60 thousand dollars
Step 2: Calculate Q1
The lower half is:
50, 52, 55 Its middle value is 52.
Q1 = 52
Step 3: Calculate Q3
The upper half is:
62, 65, 500 Its middle value is 65.
Q3 = 65
Step 4: Calculate IQR
IQR = Q3 − Q1 = 65 − 52 = 13 Step 5: Calculate the IQR boundaries
Lower bound = 52 − 1.5 × 13 = 52 − 19.5 = 32.5 Upper bound = 65 + 1.5 × 13 = 65 + 19.5 = 84.5 Since 500 is greater than 84.5, the salary is flagged as a potential upper outlier.
Step 6: Remove the observation for comparison
If a separate investigation determines that the $500,000 salary does not belong in the target employee population, the remaining salaries are:
50, 52, 55, 60, 62, 65 Step 7: Calculate the new median
There are now six observations, so the median is the average of the third and fourth values:
Median = (55 + 60) / 2 = 115 / 2 = 57.5 The new median is therefore $57,500.
| Measure | Before removal | After removal |
|---|---|---|
| Observations | 7 | 6 |
| Median | $60,000 | $57,500 |
| Change | −$2,500 | |
Why removal may be misleading
Imagine that the $500,000 salary belongs to the company's chief executive officer. It is unusual, but it is not necessarily incorrect.
Removing it because it is statistically unusual could create a cleaner-looking dataset while simultaneously deleting important information about the company's compensation structure.
If the purpose of the analysis is to understand the typical salary of non-executive employees, it may be reasonable to analyze that population separately. But the correct solution is not necessarily to pretend the executive salary never existed.
9. Why Removing an Outlier Can Change the Median
This is the central mathematical idea of the article.
People sometimes assume that because an extreme observation has little influence on the median, removing it should have almost no effect. That assumption confuses two different operations: changing the value of an observation and deleting the observation itself.
Suppose the original ordered dataset is:
50, 52, 55, 60, 62, 65, 500 The dataset has seven observations. The median position is:
(7 + 1) / 2 = 4 Therefore, the fourth observation, 60, is the median.
Now delete 500.
50, 52, 55, 60, 62, 65 There are now six observations. There is no single middle observation. Instead, the central positions are:
n / 2 = 6 / 2 = 3 n / 2 + 1 = 4 The median is therefore based on observations three and four:
(55 + 60) / 2 = 57.5 The value 500 did not move the original median toward 500. Instead, removing it caused the median definition to switch from one central observation to the average of two central observations.
10. Mathematical Explanation of the Median
Let an ordered dataset contain n observations:
x₁ ≤ x₂ ≤ x₃ ≤ ... ≤ xโ If n is odd, the median is:
x(n+1)/2
If n is even, the median is:
(xn/2 + xn/2+1) / 2
These formulas explain why deleting even a distant observation can change the median.
Seven observations
For n = 7:
(7 + 1) / 2 = 4 So the fourth ordered observation determines the median.
Six observations
For n = 6:
n / 2 = 3 n / 2 + 1 = 4 Therefore the median becomes the average of positions three and four.
Household example mathematically
For:
200, 220, 240, 250, 260, 5000 n = 6, so:
Median = (x₃ + x₄) / 2 = (240 + 250) / 2 = 245 After removing 5000:
200, 220, 240, 250, 260 n = 5, so:
Median = x₃ = 240 Therefore the median changes from 245 to 240.
The difference is not "skewing" in the same sense as the mean
This distinction deserves emphasis. A common educational shortcut is to say: "The outlier skewed the median." While the statement may communicate that the result changed, it is not the most precise mathematical description.
The original median was calculated from two central observations. Once the outlier was removed, the dataset contained a different number of observations and the median was calculated differently. The extreme value was not directly averaged into the original median.
11. An Outlier Is Not Automatically an Error
One of the most important principles in data analysis is that unusual does not mean incorrect.
Consider several possible reasons why a value may be an outlier:
- Data-entry mistake.
- Incorrect unit conversion.
- Duplicate transaction.
- Sensor malfunction.
- Exceptional but legitimate event.
- Different customer segment.
- Different employee category.
- Seasonal event.
- Fraudulent transaction.
- Rare but genuine observation.
- Structural change in the process.
- Incorrect population definition.
Each situation requires a different response.
Example: Data-entry error
Suppose a monthly expense should have been 500 but was entered as 5000. If the source document confirms that the correct amount is 500, correcting the value is preferable to simply deleting it. The problem is not that the observation is unusual; the problem is that the recorded value is wrong.
Example: Legitimate exceptional expense
If a household really spent 5000 because it purchased an appliance or paid a major medical bill, deleting the observation would remove genuine economic information.
Example: Different population
A $500,000 executive salary may be a valid observation but may not belong in an analysis intended specifically to estimate the typical salary of non-executive staff. In that case, segmentation is often better than deletion.
12. When Should an Outlier Be Removed?
Removing an observation can be appropriate when there is a defensible reason independent of the desire to obtain a particular statistical result.
Reason 1: Confirmed data error
If an observation is demonstrably incorrect and cannot be corrected, excluding it may be appropriate.
Reason 2: Measurement failure
If a sensor malfunctioned, a scale was broken, or an instrument produced an invalid reading, the resulting value may not represent the underlying phenomenon.
Reason 3: Duplicate record
Duplicate observations can artificially inflate a dataset. If the duplicate is confirmed, removing the duplicate is a data-cleaning operation rather than arbitrary statistical manipulation.
Reason 4: Explicit population criteria
An analysis may deliberately exclude observations outside its defined population. For example, a study of ordinary residential electricity consumption may have a clearly stated rule excluding industrial properties.
Reason 5: Known protocol violation
In an experiment, an observation might be excluded if a predefined protocol was violated. The important point is that the exclusion criterion should ideally be defined before examining whether the observation changes the desired result.
13. When Should an Outlier Be Kept?
An observation should generally remain in the analysis when it is legitimate and belongs to the population being studied.
Keeping an outlier may be especially important when the purpose of the analysis is to understand extreme events.
- Fraud detection requires unusual transactions.
- Cybersecurity monitoring requires unusual network activity.
- Insurance analysis needs rare claims.
- Risk management needs extreme losses.
- Emergency planning needs unusually large events.
- Income inequality analysis requires high-income observations.
- Compensation analysis may require executive salaries.
- Medical research may need to preserve rare but genuine outcomes.
In such cases, the outlier may be the most informative observation in the dataset.
Removing it simply because it makes a chart or statistic look less convenient can produce a cleaner-looking analysis while making the analysis less truthful.
14. Potential Pitfalls of Removing Outliers
Pitfall 1: Hiding important information
The first major risk is information loss. A rare event may tell us something important about the underlying system.
Pitfall 2: Creating selection bias
If observations are removed selectively, the remaining sample may no longer represent the population of interest.
Pitfall 3: Changing the business question
A dataset containing all salaries answers one question: "What does the company's full salary distribution look like?" Removing executives answers a different question: "What does the salary distribution look like among the remaining employees?"
Pitfall 4: Manipulating results unintentionally
If an analyst repeatedly tests different exclusion rules and chooses the one that produces the most favorable median, the process becomes vulnerable to analytical bias.
Pitfall 5: Confusing robustness with irrelevance
The fact that the median is robust does not mean extreme observations are irrelevant. Robustness means that the statistic does not react strongly to the magnitude of extreme values. It does not mean the observations have no analytical importance.
Pitfall 6: Ignoring sample size
In very small datasets, removing even one observation can substantially change the distribution. A six-observation dataset becoming a five-observation dataset is a major proportional change.
Pitfall 7: Treating IQR as a universal truth
The 1.5 × IQR rule is useful, but it is a convention. It is not a guarantee that every flagged observation is erroneous or every unflagged observation is valid.
Expand: A useful analytical question
Instead of asking only "Is this an outlier?", ask: "Why is this observation different, and does that difference matter for the question I am trying to answer?"
This question shifts the analysis from mechanical data cleaning to meaningful statistical reasoning.
15. Code Example: Detecting Outliers and Comparing Medians
The following Python example demonstrates the complete process for the household expense dataset. It calculates the original median, determines quartiles, calculates IQR boundaries, identifies potential outliers, removes the flagged observation for comparison, and calculates the new median.
The code is intentionally explicit so that each mathematical step can be connected to the statistical explanation.
from statistics import median data = [200, 220, 240, 250, 260, 5000] # Original median original_median = median(data) # Median-of-halves quartiles lower_half = data[:len(data) // 2] upper_half = data[(len(data) + 1) // 2:] q1 = median(lower_half) q3 = median(upper_half) iqr = q3 - q1 lower_bound = q1 - 1.5 * iqr upper_bound = q3 + 1.5 * iqr outliers = [ x for x in data if x < lower_bound or x > upper_bound ] cleaned_data = [ x for x in data if x not in outliers ] new_median = median(cleaned_data) print("Original data:", data) print("Original median:", original_median) print("Q1:", q1) print("Q3:", q3) print("IQR:", iqr) print("Lower bound:", lower_bound) print("Upper bound:", upper_bound) print("Potential outliers:", outliers) print("Data after removal:", cleaned_data) print("New median:", new_median) Notice that the code makes a specific methodological choice for quartiles. In production analysis, it is important to use a documented quartile definition and, when appropriate, a trusted statistical library whose behavior is known and reproducible.
Why code should not automatically delete outliers
A dangerous pattern would be to write a program that detects every IQR outlier and permanently deletes it without human or domain review.
A better workflow is:
- Detect potential outliers.
- Inspect them.
- Understand their origin.
- Determine whether they belong to the target population.
- Document the decision.
- Run the analysis with and without the observation when useful.
- Report the impact transparently.
16. CLI Output Sample
A command-line interface can make statistical analysis reproducible and easy to audit. Below is an example of how the Python program could be saved as outlier_median.py and executed from a terminal.
Code example before CLI execution
python outlier_median.py Example CLI output:
$ python outlier_median.py Original data: [200, 220, 240, 250, 260, 5000] Original median: 245.0 Q1: 220 Q3: 260 IQR: 40 Lower bound: 160.0 Upper bound: 320.0 Potential outliers: [5000] Data after removal: [200, 220, 240, 250, 260] New median: 240 The output provides an audit trail of the calculation. Anyone reviewing the analysis can see exactly how the original median, quartiles, IQR, bounds, potential outlier, and revised median were obtained.
17. Interactive Exploration
The following controls allow readers to experiment with the central idea without changing the underlying article. This is useful because the effect of removing an observation becomes much easier to understand when you can observe how the dataset changes.
Interactive Median Demonstration
Try the salary dataset
Replace the values in the input box with:
50,52,55,60,62,65,500 The original median should be 60. If 500 is removed, the remaining six observations have a median of 57.5.
Try a dataset where an extreme value does not change the original median
Try:
10,20,30,40,50,10000 The median is based on 30 and 40, not on 10000. This illustrates the robustness of the median to the magnitude of an extreme observation.
Try removing the largest observation manually
Use:
10,20,30,40,50 The median is 30. Then consider what happens if 50 is removed:
10,20,30,40 The new median becomes 25 because the two central observations are now 20 and 30.
This is an excellent demonstration that even a value that does not affect the original median can affect the median after deletion because deletion changes the sample size and positional structure.
18. Before-and-After Statistical Comparison
When analyzing the effect of outlier removal, it is often useful to report both versions of the dataset rather than presenting only the cleaned result.
| Characteristic | Household Data | Salary Data |
|---|---|---|
| Original observations | 200, 220, 240, 250, 260, 5000 | 50, 52, 55, 60, 62, 65, 500 |
| Original median | 245 | 60 |
| Q1 | 220 | 52 |
| Q3 | 260 | 65 |
| IQR | 40 | 13 |
| Upper bound | 320 | 84.5 |
| Potential outlier | 5000 | 500 |
| Median after removal | 240 | 57.5 |
Percentage change in the median
We can also calculate the relative change:
Percentage change = ((new median − original median) / original median) × 100 For the household example:
((240 − 245) / 245) × 100 ≈ −2.04% For the salary example:
((57.5 − 60) / 60) × 100 ≈ −4.17% These percentages describe the numerical change in the median. They do not tell us whether the change is statistically meaningful or whether the removal itself was justified.
19. Real-World Applications
Household spending
Household spending often contains legitimate exceptional payments. A monthly median can be useful for estimating typical spending, while a separate analysis of extreme expenses can reveal financial shocks.
Employee salaries
Salary distributions are frequently right-skewed. The median can provide a more representative description of a typical employee than the mean, especially when a small number of high earners are present.
Real estate
Property prices can contain luxury transactions far above the typical market. Removing luxury properties may be appropriate when calculating a statistic for ordinary residential properties, but the luxury market should not be erased if the goal is to understand the full market.
Healthcare costs
Medical spending often contains rare, extremely expensive cases. Those cases can be outliers while still being clinically and economically important.
Business transactions
A company may have thousands of ordinary transactions and a handful of very large transactions. Those large transactions can be legitimate enterprise purchases, acquisitions, refunds, or unusual events.
Fraud detection
In fraud analytics, an outlier may be the observation analysts most want to investigate. Automatically removing it could eliminate the very signal the system was designed to discover.
Manufacturing
A sensor reading far outside normal operating conditions might be a faulty sensor reading, but it could also indicate a machine failure. Deleting it without investigation could hide a real operational problem.
20. Best Practices for Responsible Outlier Analysis
- Define the analytical question first. Decide what population and phenomenon you are trying to describe.
- Inspect the raw data. Do not begin with automatic deletion.
- Use a documented outlier rule. If using IQR, state the quartile method and threshold.
- Investigate unusual observations. Determine whether the observation is an error, a legitimate rare event, or a different population.
- Do not confuse statistical unusualness with invalidity.
- Compare results with and without potential outliers. This reveals how sensitive the conclusion is to the observation.
- Report exclusions transparently. Do not hide the original sample size or the number of removed observations.
- Consider segmentation. If an observation belongs to a different legitimate group, analyze groups separately.
- Preserve the original dataset. Never overwrite source data simply to create a cleaned dataset.
- Use reproducible code. Record the method so another analyst can reproduce the calculation.
- Use domain knowledge. Statistics can identify unusual observations, but domain expertise often explains why they are unusual.
- Communicate uncertainty. With very small samples, avoid presenting an outlier decision as universally definitive.
21. A Deeper Look at What the Two Examples Teach Us
The household and salary examples look simple, but they illustrate several fundamental principles of statistics.
First lesson: Position matters more than magnitude for the median
The median depends on the ordered position of observations. A value of 5000 does not automatically make the median large. If 5000 is at the far end of the ordered dataset, it may have little direct influence on the median.
Second lesson: Deletion changes positions
When an observation is deleted, every observation after it shifts one position toward the center in the ordered representation. More importantly, the formula for locating the middle changes because n changes.
Third lesson: Small samples are fragile
In a dataset containing millions of observations, removing one legitimate observation may have almost no practical effect on a percentile estimate. In a dataset containing six observations, removing one means deleting approximately 16.7% of the data.
Fourth lesson: A cleaned dataset is not automatically a better dataset
"Clean" can mean different things. A dataset without errors is better than a dataset with errors. But a dataset without unusual legitimate observations is not necessarily better. Sometimes the unusual observations are precisely what matter.
Fifth lesson: Statistical summaries answer specific questions
The median of all salaries and the median of non-executive salaries are both valid statistics, but they answer different questions. Problems arise when the population changes silently while the analyst continues to describe the statistic as though nothing changed.
22. Sensitivity Analysis: A Better Way to Handle Uncertainty
One useful strategy is to perform a sensitivity analysis. Instead of choosing immediately between "keep" and "remove," calculate the result under both scenarios.
For example:
| Scenario | Median |
|---|---|
| All observations included | 245 |
| 5000 excluded | 240 |
The conclusion can then say: "The median is 245 when all observations are retained and 240 when the identified potential outlier is excluded."
This is much more informative than reporting only 240 and hiding the original result.
Sensitivity analysis is particularly useful when the exclusion decision is debatable. It allows readers to see whether the substantive conclusion depends heavily on the treatment of unusual observations.
23. How to Document an Outlier Decision
In professional analytics, documentation is often as important as the calculation itself.
A useful outlier record can contain:
- Original observation.
- Dataset or table name.
- Date of observation.
- Outlier detection method.
- Q1 value.
- Q3 value.
- IQR value.
- Lower boundary.
- Upper boundary.
- Reason the observation was flagged.
- Domain investigation result.
- Final decision.
- Person or team responsible for approval.
- Effect on reported statistics.
Such documentation prevents future analysts from wondering why an observation disappeared. It also makes statistical decisions auditable.
Suggested decision record
Observation: Detection method: Q1: Q3: IQR: Lower bound: Upper bound: Reason flagged: Domain investigation: Decision: Reason for decision: Original median: Revised median: Analyst: Date: 24. Common Mistakes to Avoid
Mistake 1: Automatically deleting anything above Q3
Values above Q3 are not automatically outliers. Q3 marks approximately the upper quartile, not an error boundary.
Mistake 2: Confusing IQR with range
Range is maximum minus minimum. IQR is Q3 minus Q1. They measure different aspects of spread.
Mistake 3: Forgetting to sort the data
Median and quartile calculations depend on ordered positions. Always sort the observations or use a reliable statistical function that performs the necessary ordering.
Mistake 4: Calling every outlier an error
An outlier is an analytical signal, not a verdict.
Mistake 5: Reporting only the cleaned result
If observations were removed, disclose that fact and, where useful, report the original result.
Mistake 6: Ignoring the business context
Statistical methods are powerful, but context determines whether an unusual value is meaningful.
Mistake 7: Assuming a larger dataset is always cleaner
Adding legitimate extreme observations may make a distribution look more variable, but that does not make the dataset worse. A realistic dataset should reflect reality, including legitimate variation.
25. Frequently Asked Questions
Does removing an outlier always change the median?
No. Removing an outlier can leave the median unchanged. The effect depends on the original sample size, the location of the removed observation, and the values surrounding the center.
Is the median affected by extreme values?
The median is much less sensitive to the magnitude of extreme observations than the mean. However, deleting observations can still change the median because the central position changes.
Does an IQR outlier have to be removed?
No. The IQR rule identifies potential outliers. It does not mandate deletion.
Why use 1.5 times the IQR?
1.5 × IQR is a widely used conventional threshold for identifying observations unusually far from the central 50% of the distribution. It is a practical rule rather than an absolute law.
What is Q2?
Q2 is the second quartile and is equivalent to the median.
Why can the median decrease after removing a very large value?
Because the median depends on position. Removing a large value can change the dataset from odd to even or shift the central positions, causing a different value or average of values to become the median.
Should salary outliers be removed?
Not automatically. Executive compensation, specialist roles, bonuses, founders, or other legitimate high salaries may be important. Consider segmentation and clearly define the target population instead of automatically deleting unusual salaries.
Is the median always better than the mean?
No. The appropriate statistic depends on the analytical question and distribution. The median is particularly useful for skewed distributions and situations where robustness to extreme values is desirable.
What should I report when I remove an outlier?
Report the original sample size, the excluded observation or number of excluded observations, the exclusion criterion, the reason for exclusion, and the effect on the result whenever practical.
26. Learning Summary
The central concept can be summarized in a few connected ideas.
- The median identifies the center of an ordered dataset.
- The median is generally resistant to the magnitude of extreme observations.
- The IQR measures the spread of the middle 50% of observations.
- The common IQR rule flags values below Q1 − 1.5 × IQR or above Q3 + 1.5 × IQR.
- A flagged value is a potential outlier, not automatically an error.
- Removing an observation changes the number and positional structure of the dataset.
- Consequently, removing an outlier can change the median even though the outlier itself did not strongly influence the original median.
- Legitimate outliers can contain important information and should not be discarded automatically.
- Small datasets require particular caution because each observation has a large proportional effect.
- Sensitivity analysis and transparent reporting are often better than silently deleting observations.
27. Conclusion
Removing outliers can change the median, but understanding why it changes is more important than simply observing that it changed.
In the household expense example, the original dataset 200, 220, 240, 250, 260, 5000 has a median of 245. The value 5000 is flagged as a potential outlier using the IQR method. When it is removed, the remaining dataset has five observations and the median becomes 240.
In the salary example, 50, 52, 55, 60, 62, 65, 500 has a median of 60. After removing 500, the remaining six observations have a median of 57.5.
At first glance, these examples might suggest that the outliers were "pulling" the medians upward. That interpretation is not quite accurate. The median is deliberately resistant to extreme magnitudes. In these examples, the more precise explanation is that deleting an observation changed the number of observations and therefore changed the location or averaging rule used to identify the middle.
The IQR method provides a useful and accessible way to identify observations that deserve attention. It gives us Q1, Q3, the IQR, and statistical boundaries. But the method does not know whether a value is a data-entry mistake, a legitimate executive salary, an emergency expense, a fraudulent transaction, a rare event, or evidence of a different population.
That is why responsible data analysis separates outlier detection from outlier removal.
The strongest workflow is to detect unusual observations, investigate them, understand their context, decide whether they belong to the target population, document the decision, and compare the analysis before and after any exclusion.
If the goal is to estimate a typical value, the median can be an excellent statistic. If the goal is to understand risk, inequality, fraud, extreme events, or exceptional expenses, the outliers themselves may be among the most valuable observations in the dataset.
Ultimately, the goal of statistics is not to make data look normal. The goal is to describe reality accurately enough to support sound reasoning and better decisions.
An unusual observation should therefore trigger a question, not an automatic delete operation.
No comments:
Post a Comment