Complete Guide to IQR Method
Outlier Detection
Learn how the Interquartile Range (IQR) method detects outliers using quartiles and Tukey fences. Follow step-by-step calculations and compare IQR to other robust outlier detection techniques.
1. What is the IQR Method?
The Interquartile Range (IQR) method detects outliers by measuring the middle 50% of a dataset. It uses quartiles (Q1 and Q3) to identify data points that fall significantly below or above the majority of values.
IQR-based outlier detection is widely used because it is non-parametric (no distribution assumptions) and robust to extreme values.
๐ก Key Formula
IQR = Q3 โ Q1
Q1 is the 25th percentile, Q3 is the 75th percentile.
2. How to Calculate IQR Step-by-Step
Step-by-Step Workflow
- Sort the dataset in ascending order.
- Compute Q1 (lower quartile): the median of the lower half of data.
- Compute Q3 (upper quartile): the median of the upper half of data.
- Calculate IQR: subtract Q1 from Q3.
๐ Example Dataset
Data: [12, 14, 16, 19, 22, 24, 27, 35]
Q1 = median of [12, 14, 16, 19] = (14 + 16) / 2 = 15
Q3 = median of [22, 24, 27, 35] = (24 + 27) / 2 = 25.5
IQR = 25.5 โ 15 = 10.5
3. Tukey Fences and Outlier Classification
Tukey fences define the boundaries beyond which data points are flagged as outliers. The standard multipliers are 1.5รIQR for "mild" outliers and 3.0รIQR for "extreme" outliers.
Standard Fences
- Lower Fence: Q1 โ 1.5 ร IQR
- Upper Fence: Q3 + 1.5 ร IQR
- Points outside fences = potential outliers
Extended Fences
- Lower Extreme Fence: Q1 โ 3 ร IQR
- Upper Extreme Fence: Q3 + 3 ร IQR
- Points beyond extreme fences = strong anomalies
โ ๏ธ Remember
The 1.5รIQR multiplier is a convention, not a universal rule. For sensitive domains like finance or healthcare, adjust the multiplier or compare with robust methods like MAD outlier detection.
4. Worked Examples
Example 1: Quality Control Data
Scenario: Manufacturing sensor readings (units: mm): [10.1, 10.3, 10.4, 10.5, 10.6, 10.7, 10.9, 12.0]
- Q1 = 10.35, Q3 = 10.8 โ IQR = 0.45
- Lower fence = 10.35 โ 1.5 ร 0.45 = 9.675
- Upper fence = 10.8 + 1.5 ร 0.45 = 11.475
- Value 12.0 exceeds the upper fence โ flagged as outlier
Example 2: Customer Spending
Scenario: Monthly spending for 12 customers (USD): [120, 140, 155, 160, 170, 175, 180, 190, 205, 210, 225, 500]
- Q1 = 157.5, Q3 = 205 โ IQR = 47.5
- Upper fence = 205 + 1.5 ร 47.5 = 276.25
- Value 500 is an outlier โ investigate spending anomaly
5. Advantages & Limitations
โ Advantages
- Robust to extreme values
- No distribution assumptions
- Simple to explain and implement
- Powers standard box plot visualizations
- Works well with skewed distributions
โ ๏ธ Limitations
- Assumes consistent scale across data
- Threshold (1.5รIQR) may need tuning
- Can miss clusters of legitimate extreme values
- Not ideal for very small sample sizes
6. IQR vs Other Outlier Detection Methods
| Method | Best For | Strengths | Considerations |
|---|---|---|---|
| IQR (1.5ร) | General-purpose, skewed data | Robust to outliers, easy to explain | Threshold may need adjustment |
| MAD | Highly skewed or heavy-tailed data | Uses median-based scale, very robust | Less intuitive, requires modified Z-score |
| Z-Score | Normally distributed data | Simple computation | Sensitive to outliers and skewness |
| Percentile Rules | Custom thresholds (e.g., 1st/99th) | Flexible | Requires domain knowledge |
Combine IQR with MAD detection or enable notched box plots in PlotNerd to highlight statistical significance.
7. Implementation Checklist
- Ensure data is numeric and free from invalid entries
- Decide whether to include/exclude outliers after detection
- Document the multiplier (1.5ร or custom) used in reports
- Report central tendency alongside spread (see mean vs median vs mode).
- Compare IQR results with MAD for heavy-tailed data
- Visualize results in PlotNerd to communicate findings
8. FAQ
Q: Can I change the 1.5ร multiplier?
A: Yes. Adjust the multiplier based on your tolerance for outliers. For highly regulated industries, consider 1.0ร. For exploratory analysis, 2.0ร can reduce false positives.
Q: Does IQR work on small datasets?
A: IQR is less reliable when sample size < 8. In such cases, supplement with domain knowledge or collect more data.
Q: How does IQR handle skewed data?
A: IQR performs well with skewed data because it focuses on quartiles. For heavily skewed distributions, compare results with MAD detection.
Q: Can I automate IQR detection?
A: Yes. Use PlotNerd's calculator or implement IQR logic in code (R, Python, Excel). Always log the multiplier and decisions for audit trails.
9. Conclusion
The IQR method is a reliable starting point for outlier detection. It balances simplicity with robustness, making it ideal for exploratory data analysis, reporting, and automated quality checks.
Combine IQR with visual tools like box plots and additional metrics (MAD, z-scores) to validate findings and communicate insights effectively.
Ready to Detect Outliers?
Use PlotNerd's IQR Outlier Detector to compute quartiles, IQR, and Tukey fences instantly. Supports both Tukey and MAD methods for robust outlier detection.
Open IQR Outlier Detector๐ Related Articles
- โ MAD vs Tukey: Choosing the Right Outlier Detection Method
- โ What are Quartiles? Complete Beginner's Guide
- โ Understanding Notched Box Plots: Statistical Significance Visualization
- โ How to Compare Multiple Groups with Grouped Box Plots
- โ How to Read a Box Plot: A Simple Guide
- โ Box Plot in Excel (2025) โ Step-by-Step Guide
๐ ๏ธ Related Tools
- โ IQR Outlier Detector Tool โ Detect outliers using Tukey and MAD methods
- โ Quartile Calculator โ Calculate quartiles and create box plots