Grubbs’ test
Goodness of fit and normality · reference distribution: G (critical value via t)
When to use it
Check whether the most extreme value in a sample is an outlier, that is, too far away to come from the same normal distribution as the others.
Null hypothesis
There is no outlier: all values come from the same normal distribution.
Assumptions
- Normal data, apart from the possible outlier
- It looks for one outlier at a time: repeating the test after removing one inflates the type I error
Test statistic
G = \dfrac{\max_i |x_i - \bar{x}|}{s}How to report it
G = 2.91, n = 20, p = .017: the largest value is an outlier
In R and Python
R
library(outliers)
grubbs.test(x)
Python
n = len(x)
G = np.abs(x - x.mean()).max() / x.std(ddof=1)
t = stats.t.ppf(1 - 0.05 / (2 * n), n - 2)
G_crit = (n - 1) / np.sqrt(n) * np.sqrt(t**2 / (n - 2 + t**2))
In Python, stats is scipy.stats and np is numpy.
Variants and alternatives
- Dixon’s Q, for very small samples
- Rosner’s generalized ESD, to look for several outliers at once
Where it sits in the catalog
Goodness of fit and normality. Goodness of fit: do the data follow the expected distribution? Normality tests are the most common case and check an assumption of parametric tests.
In the decision tree
- What do you want to do? Check an assumption or the distribution of the data
- What do you want to check? Whether an extreme value is an outlier