Skip to content

ADescribe · Guide test 150

Generalized ESD or Rosner test

Tests for multiple outliers up to a specified maximum, with adjusted sequential critical values.

Runs in CodeSplashPython (calls R) example not runR example not run

Do it in CodeSplash

In the app, set it up in Analyze with this method:

Do it in CodeSplash Run this test on your own data, in Python or R.

Bench

Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.

Bench · Generalized ESD (Rosner) test

30
2
4.0

How far the planted values sit above the rest.

3
0.050

Your data

Drag a point away from the rest
Sample · n = 30 · mean 0.43

If H₀ were true

z = 1.22
  1. The reference: how z varies across samples when H₀ is true (the procedure's p (smallest α at which a stage rejects), shown on the normal scale z = Φ⁻¹(1 − p)).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .112).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

Ri=max⁡∣x−xˉ∣s (after removing i−1),λi=(n−i) tp, n−i−1(n−i−1+t2)(n−i+1)R_i = \dfrac{\max |x - \bar x|}{s}\ \text{(after removing } i-1\text{)},\quad \lambda_i = \dfrac{(n-i)\,t_{p,\,n-i-1}}{\sqrt{(n-i-1+t^2)(n-i+1)}}

With your numbers

R1=2.66,λ1=2.91,outliers declared=0R_1 = 2.66,\quad \lambda_1 = 2.91,\quad \text{outliers declared} = 0
RiR_i
Grubbs statistic at stage i
λi\lambda_i
its critical value, p = 1 − α/(2(n − i + 1))
rr
the largest number of outliers considered

The verdict

R₁ = 2.66, z = 1.22, p = .112

p > α = .050: compatible with H₀

Run all r stages and declare the largest i with R_i > λ_i, not the first rejection: a second outlier can mask the first.

Statistic
1.217
p-value
0.1118
Generalized ESD (Rosner) test on Sample: n = 30: R1 = 2.66, z = 1.22, p = .112. The p-value is above α = .050, so the data are compatible with H0.

Generalized ESD (Rosner) test on Sample: n = 30: R₁ = 2.66, z = 1.22, p = .112. The p-value is above α = .050, so the data are compatible with H₀.

Question and hypotheses

H0: no outliers; H1: up to r observations are outliers.

Assumptions

Approximately normal uncontaminated population; independent observations; prespecified maximum r.

Formula

Ri=max⁡j∣xj−xˉi∣siλi=(n−i)ti(n−i−1+ti2)(n−i+1)\begin{gathered}R_i=\max_j\frac{|x_j-\bar x_i|}{s_i}\\[5pt]\lambda_i=\frac{(n-i)t_i}{\sqrt{(n-i-1+t_i^2)(n-i+1)}}\end{gathered}

Parameters and notation

At step i compute mean/SD on remaining n−i+1 values, remove the most extreme; ti is the t quantile at 1−α/[2(n−i+1)] with n−i−1 df.

Structure of the method

Sequentially remove the most extreme standardized observation, recomputing center and scale at each stage up to the fixed maximum r. Compare the complete sequence with stage-specific critical values and choose the largest significant stage, rather than stopping at the first nonrejection.

Estimated and nuisance parameters

Means and standard deviations are re-estimated on each reduced sample. The final outlier count and candidate order are outputs of the procedure; the upper bound r is externally selected.

Settings and design choices

Choose maximum r, significance level and the exact Rosner implementation before screening. The procedure’s built-in sequential rule is not equivalent to repeatedly performing independent Grubbs tests at an unchanged alpha.

Fitting and adaptation

Run every requested stage, retain its statistic/threshold and apply the final largest-index decision. On new batches repeat the full sequence. There are no trained parameters to transfer. Use the outcome to guide data-quality investigation and sensitivity analyses; changing r after inspecting results requires a new selection-aware calibration or a transparent exploratory label.

Sensitivity and robustness

The uncontaminated distribution must be approximately normal. Too large an r can leave unstable reduced samples; too small a bound can miss contamination. Heavy tails, dependence and masking alter behavior. The test identifies incompatibility with a model, not whether a scientifically unusual observation should be deleted.

How to use and calibrate

Run all r stages. Declare the largest i for which Ri>λi as the number of outliers, not merely the first rejection.

Example application

Screen a normal quality-control sample allowing several anomalous observations.

Interpretation and pitfalls

Watch out

The stepwise decision rule matters. Outlier identification is not authorization to delete valid scientifically unusual data.

What changed in edition 2

  • New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.

Python and R

Generalized ESD allows up to r=3 outliers. Do not substitute a series of ordinary Grubbs tests.

Python · invokes R

Not run — Python launcher syntax checked; R backend runtime not verified · needs Python standard library + Rscript; R packages: PMCMRplus

# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
    raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
set.seed(2026)
x <- rnorm(60)
x[1:2]<-c(5,6);print(PMCMRplus::gesdTest(x,maxr=3))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
                        text=True, capture_output=True)
print(result.stdout)
if result.stderr:
    print(result.stderr)
result.check_returncode()
R

Not run — Syntax checked; runtime not verified in the final environment · needs PMCMRplus

set.seed(2026)
x <- rnorm(60)
x[1:2]<-c(5,6);print(PMCMRplus::gesdTest(x,maxr=3))

Sources

Statistics guide v4 (historical):
Python: Python launcher syntax checked; R backend runtime not verified · R: Syntax checked; runtime not verified in the final environment
Reference's record:
Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.

From the CodeSplash statistics guide (v4), entry 150, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT150.