How to Calculate Interquartile Range

The interquartile range (IQR) is a measure of statistical dispersion that describes the spread of the middle 50% of a dataset.

Unlike the range, which uses the minimum and maximum values, the IQR is based on the first and third quartiles. This makes it particularly useful for datasets containing outliers or skewed distributions.

The interquartile range is widely used in statistics, data analysis, exploratory data analysis (EDA), and box plots.

What Is the Interquartile Range?

The interquartile range is the difference between the third quartile and the first quartile:

[
\boxed{IQR = Q3 – Q1}
]

Where:

  • Q1 (First Quartile): The 25th percentile of the data.
  • Q2 (Second Quartile): The median, or 50th percentile.
  • Q3 (Third Quartile): The 75th percentile.

Therefore, the IQR represents the range covered by the central 50% of observations.

For example, if:

[
Q1 = 36
]

and

[
Q3 = 49
]

then:

[
IQR = 49 – 36 = 13
]

The interquartile range is 13.

Why Is the IQR Useful?

The IQR is an important measure of variability because it is relatively resistant to extreme observations.

It can be used to:

  • Measure the spread of the middle 50% of observations.
  • Compare variability between datasets.
  • Identify potential outliers.
  • Summarize skewed distributions.
  • Construct and interpret box plots.
  • Perform exploratory data analysis.

For example, consider two datasets with similar medians but very different IQRs. The dataset with the larger IQR has greater variability among its central observations.

How to Calculate the IQR Step by Step

Consider the following dataset:

7, 15, 36, 39, 42, 43, 46, 49, 52, 56

The data is already arranged in ascending order.

Step 1: Sort the Data

Always arrange observations from the smallest to the largest value before calculating quartiles.

[
7,\ 15,\ 36,\ 39,\ 42,\ 43,\ 46,\ 49,\ 52,\ 56
]

There are:

[
n = 10
]

observations.

Step 2: Find the Median (Q2)

Because there are 10 observations, the dataset has an even number of values.

The two middle observations are 42 and 43.

Therefore:

[
Q2 = \frac{42+43}{2}=42.5
]

The median is 42.5.

Step 3: Divide the Dataset into Two Halves

Using the common median-of-halves method, divide the data into a lower and upper half.

Lower half:

[
7,\ 15,\ 36,\ 39,\ 42
]

Upper half:

[
43,\ 46,\ 49,\ 52,\ 56
]

The overall median is not included in either half in this example because the dataset contains an even number of observations.

Step 4: Calculate Q1

Q1 is the median of the lower half:

[
7,\ 15,\ 36,\ 39,\ 42
]

The middle value is:

[
Q1 = 36
]

Step 5: Calculate Q3

Q3 is the median of the upper half:

[
43,\ 46,\ 49,\ 52,\ 56
]

The middle value is:

[
Q3 = 49
]

Step 6: Calculate the IQR

Now apply the IQR formula:

[
IQR = Q3-Q1
]

[
IQR = 49-36
]

[
\boxed{IQR=13}
]

Therefore, the interquartile range of this dataset is 13.

How to Use IQR to Identify Outliers

The IQR is also commonly used in the 1.5 × IQR rule for identifying potential outliers.

First calculate:

[
IQR=Q3-Q1
]

Then calculate the lower and upper fences:

[
\text{Lower Fence}=Q1-1.5(IQR)
]

[
\text{Upper Fence}=Q3+1.5(IQR)
]

Using our example:

[
Q1=36
]

[
Q3=49
]

[
IQR=13
]

Lower fence:

[
36-1.5(13)=16.5
]

Upper fence:

[
49+1.5(13)=68.5
]

Therefore, observations below 16.5 or above 68.5 would be flagged as potential outliers using this rule.

In our dataset, 7 and 15 fall below the lower fence.

It is important to remember that an observation identified by this rule is generally considered a potential outlier, not automatically an error. It may represent a legitimate and important observation.

IQR vs. Range

Both the range and IQR measure dispersion, but they behave differently.

MeasureFormulaUsesSensitivity to Outliers
RangeMaximum − MinimumEntire spreadHigh
IQRQ3 − Q1Middle 50%Low

For example, a single extremely large observation can dramatically increase the range while having little effect on the IQR.

This makes the IQR particularly useful for skewed distributions and datasets containing extreme values.

IQR and Box Plots

The IQR is also a key component of a box plot.

A standard box plot displays:

  • Minimum or lower whisker
  • Q1
  • Median
  • Q3
  • Maximum or upper whisker

The box itself extends from Q1 to Q3.

Therefore:

[
\text{Width of box}=IQR
]

Potential outliers are often displayed separately beyond the whiskers, depending on the box-plot convention being used.

Different Methods for Calculating Quartiles

One important consideration is that quartiles are not defined by a single universal computational algorithm.

Different statistical software packages, programming languages, textbooks, and calculators may use different quartile definitions or interpolation methods.

For example, software may calculate percentiles using different formulas based on the position of observations in the ordered dataset.

As a result, two tools can occasionally produce slightly different values for Q1, Q3, and consequently the IQR.

When precision matters:

  1. State which quartile method you are using.
  2. Use the same method consistently.
  3. Check the documentation of the statistical software or calculator.

For educational examples, the median-of-halves approach is often convenient and easy to explain.

IQR vs. Standard Deviation

The IQR and standard deviation both measure variability, but they answer different questions.

IQR describes the spread of the middle 50% of observations and is relatively resistant to outliers.

Standard deviation measures the typical distance of observations from the mean and is more sensitive to extreme values.

For approximately symmetric distributions without major outliers, standard deviation can be very informative.

For skewed distributions or data with extreme observations, the median and IQR are often more appropriate summary statistics.

Applications of the Interquartile Range

The IQR is commonly used in:

  • Exploratory data analysis
  • Finance
  • Healthcare research
  • Quality control
  • Economics
  • Survey analysis
  • Business analytics
  • Machine learning preprocessing
  • Statistical reporting

In machine learning and data preprocessing, IQR-based methods can also be useful for investigating unusual observations before model development.

However, outliers should not automatically be removed simply because they fall outside the 1.5 × IQR fences. Their cause and relevance should be investigated first.

Frequently Asked Questions

What is the formula for IQR?

The formula is:

[
\boxed{IQR=Q3-Q1}
]

What does IQR represent?

The IQR represents the spread of the middle 50% of observations in a dataset.

Is IQR affected by outliers?

The IQR is relatively resistant to outliers because it uses Q1 and Q3 rather than the minimum and maximum values.

What is the 1.5 IQR rule?

The 1.5 × IQR rule identifies observations below:

[
Q1-1.5(IQR)
]

or above:

[
Q3+1.5(IQR)
]

as potential outliers.

Can IQR be negative?

No. Since Q3 is greater than or equal to Q1, the IQR cannot be negative.

What is the difference between IQR and range?

The range is the difference between the maximum and minimum values, while the IQR is the difference between Q3 and Q1.

Conclusion

The interquartile range (IQR) is a simple but powerful measure of statistical dispersion.

To calculate it:

  1. Sort the data.
  2. Find Q1.
  3. Find Q3.
  4. Subtract Q1 from Q3.

[
\boxed{IQR=Q3-Q1}
]

Because the IQR focuses on the middle 50% of observations, it is particularly useful when analyzing skewed data or datasets containing extreme values.

Understanding the IQR also provides a foundation for interpreting box plots, detecting potential outliers, and performing exploratory data analysis.

You can also calculate the IQR online using the Interquartile Range (IQR) Calculator.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

eleven − 5 =