ADescribe · Guide test 150
Generalized ESD or Rosner test
Tests for multiple outliers up to a specified maximum, with adjusted sequential critical values.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Outliers (univariate) — Which values of a numeric variable are unusually far from the rest?
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
How far the planted values sit above the rest.
Your data
Drag a point away from the restIf H₀ were true
- 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)).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .112).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- Grubbs statistic at stage i
- its critical value, p = 1 − α/(2(n − i + 1))
- 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: 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
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.
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()
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
- PMCMRplus — PMCMRplus · gesdTestAuthor documentation/source reviewed: PMCMRplus 1.9.12.search.r-project.org
- gesdTestsearch.r-project.org
- 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.