Português

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

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

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

  1. What do you want to do? Check an assumption or the distribution of the data
  2. What do you want to check? Whether an extreme value is an outlier

Open the decision tree