ADescribe · Guide test 149
Tietjen–Moore test
Tests for a prespecified number of outliers in an approximately normal sample.
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 · Tietjen–Moore 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 E_k varies across samples when H₀ is true, E_k for n = 25, k = 2 (Monte Carlo null: 1,999 samples simulated under H₀ (seed 20261107)).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .009).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- share of the total sum of squares left after removing the k most distant values
- number of suspected outliers, fixed in advance
The verdict
E_k = 0.42, p = .009
p ≤ α = .050: reject H₀
Small E_k means the removed values carried much of the spread. k must be chosen before looking; testing several k is a different procedure (generalized ESD).
- Statistic
- 0.420
- p-value
- 0.0095
Tietjen–Moore test on Sample: n = 25: E_k = 0.42, p = .009. The p-value is below α = .050, so the data are hard to reconcile with H₀.
Question and hypotheses
H0: no outliers; H1: exactly k specified extreme candidates are outliers.
Assumptions
Independent normal observations except potential contaminants; k and one/two sided form fixed in advance.
Formula
Parameters and notation
R retains n−k values after removing the specified extreme candidates; two sided implementations rank absolute deviations to choose candidates.
Structure of the method
Identify the prespecified number k of extreme candidates using the declared one- or two-sided ranking rule. Compare residual variation among retained observations with total residual variation; small ratios indicate unusually large reduction after removal.
Estimated and nuisance parameters
Estimate a full-sample mean and a retained-sample mean. Candidate identities are selected by the rule, but k is a prespecified design choice rather than a parameter estimated without penalty.
Settings and design choices
Fix k, sidedness, significance level and simulation budget. The two-sided absolute-deviation ranking and the one-sided ordered-tail rule are different algorithms and must not share unverified critical values.
Fitting and adaptation
Simulate normal samples of the same size and rerun candidate selection, both mean calculations and the variance ratio for every replicate. Refit for each new batch; this is selection-aware null calibration, not fine-tuning. If k is unknown, use a method designed for an upper bound rather than trying many k values and reporting one unadjusted result.
Sensitivity and robustness
Incorrect k can reduce power or cause misinterpretation, and multiple outliers may mask one another. A legitimate heavy-tailed distribution can trigger rejection. Degenerate retained variance, duplicated values, dependence and selection of k after viewing the data all require explicit investigation before any exclusion decision.
How to use and calibrate
Small Ek rejects; critical values are usually obtained by simulation of the entire selection rule under a normal null.
Example application
Check a prespecified suspicion that two measurements are contaminated.
Interpretation and pitfalls
Watch out
The method needs k in advance; it does not estimate an arbitrary number of outliers without further calibration.
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
Two-sided Tietjen–Moore with the number of suspected outliers k=2 specified in advance. Small residual/total sums-of-squares ratio is evidence against the null.
Not run — Executed end to end through Rscript · needs Python standard library + Rscript; R packages: base R
# 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);k<-2
TM<-function(x,k) {keep<-order(abs(x-mean(x)))[seq_len(length(x)-k)];sum((x[keep]-mean(x[keep]))^2)/sum((x-mean(x))^2)}
T<-TM(x,k);B<-999;null<-replicate(B,TM(rnorm(length(x)),k))
print(c(statistic=T,p=(1+sum(null<=T))/(B+1)))
"""
# 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()
Validated — Executed successfully in the validation environment · needs Base/standard library
set.seed(2026)
x <- rnorm(60)
x[1:2]<-c(5,6);k<-2
TM<-function(x,k) {keep<-order(abs(x-mean(x)))[seq_len(length(x)-k)];sum((x[keep]-mean(x[keep]))^2)/sum((x-mean(x))^2)}
T<-TM(x,k);B<-999;null<-replicate(B,TM(rnorm(length(x)),k))
print(c(statistic=T,p=(1+sum(null<=T))/(B+1)))
Output
statistic p 0.4546189 0.0010000
Sources
- www.itl.nist.gov/div898/handbook/eda/section3/eda35h2.htmitl.nist.gov
- eda35h2.htmitl.nist.gov
- Statistics guide v4 (historical):
- Python: Executed end to end through Rscript · R: Executed successfully in the validation 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 149, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT149.