Skip to content

ADescribe · Guide test 151

Bonferroni studentized residual outlier test

Tests unusual regression observations using externally studentized residuals with a multiplicity adjustment.

Runs in CodeSplashPython example validatedR example validated

Do it in CodeSplash

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

In Linear regression (OLS), choose Residual diagnostics = Full battery.

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 · Bonferroni studentized residual outlier test

40
0.30
4.0
0.050

Your data

Simulated with a known ρ

If H₀ were true

|t|max = 2.43
  1. The reference: how |t|max varies across samples when H₀ is true, largest |studentized residual|, n = 40 (Bonferroni) (Bonferroni: n × the two-sided t tail).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .805).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

ti=eis(i)1−hii,p=min⁡(1, n⋅2P(Tn−3>∣t∣max⁡))t_i = \dfrac{e_i}{s_{(i)}\sqrt{1-h_{ii}}},\qquad p = \min\bigl(1,\ n \cdot 2P(T_{n-3} > |t|_{\max})\bigr)

With your numbers

∣t∣max⁡=2.43,p=40×0.02|t|_{\max} = 2.43,\qquad p = 40 \times 0.02
tit_i
externally studentized residual: the fit without observation i
hiih_{ii}
leverage
s(i)s_{(i)}
residual SD without observation i

The verdict

|t|max = 2.43, p = .805

p > α = .050: compatible with H₀

The Bonferroni factor n accounts for looking at every residual. Rejecting flags the observation for checking, not for deletion.

Statistic
2.429
p-value
0.8052
Bonferroni studentized residual outlier test on 40 (x, y) pairs: |t|max = 2.43, p = .805. The p-value is above α = .050, so the data are compatible with H0.

Bonferroni studentized residual outlier test on 40 (x, y) pairs: |t|max = 2.43, p = .805. The p-value is above α = .050, so the data are compatible with H₀.

Question and hypotheses

H0: all observations conform to the fitted normal linear model.

Assumptions

Correct full rank linear model with independent normal homoskedastic errors; no unaccounted model selection.

Formula

ti=eis(i)1−hiipiadj=min⁡{1, 2nP(tn−p−1≥∣ti∣)}\begin{gathered}t_i=\frac{e_i}{s_{(i)}\sqrt{1-h_{ii}}}\\[5pt] p_i^{adj}=\min\{1,\,2nP(t_{n-p-1}\ge|t_i|)\}\end{gathered}

Parameters and notation

ei residual; hii leverage; s(i) residual SD fitted without observation i; p coefficient count.

Structure of the method

Fit a full-rank linear model, compute leverage and externally studentized residuals using deletion-adjusted error variance, then convert each residual to a t-tail probability. Bonferroni multiplication accounts for examining the candidate observations as a family.

Estimated and nuisance parameters

Regression coefficients, residual variance and each leave-one-out variance estimate are fitted nuisance quantities. The leverage matrix is determined by the design; it measures predictor extremeness rather than response outlyingness.

Settings and design choices

Prespecify the model formula, transformations, candidate family and alpha. Reporting cutoffs and maximum printed rows are display settings, not changes to the multiplicity denominator. Model selection on the same data adds uncertainty not covered by the basic formula.

Fitting and adaptation

Refit the regression and deletion diagnostics for new data. If the model changes, recompute leverage, residual degrees of freedom and the complete adjustment. Neural fine-tuning does not apply. Validate normality, mean structure and error variance assumptions, and distinguish response-outlier screening from leverage and influence diagnostics before deciding on remediation.

Sensitivity and robustness

High leverage can hide large prediction deviations; heteroskedastic or correlated errors invalidate ordinary t calibration. A misspecified mean function can make systematic structure look like outliers. Bonferroni handles dependence among valid individual p-values, but it cannot repair invalid individual tests or unaccounted model searching.

How to use and calibrate

Compute externally studentized residuals and Bonferroni-adjust across candidate observations.

Example application

Identify a response unusually far from its regression prediction.

Interpretation and pitfalls

Watch out

Large leverage and influence are distinct from a large residual. The normal error model is important for the t reference.

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

Externally studentized residual tests with Bonferroni adjustment; an influential point and a residual outlier are different concepts.

Python · native

Validated — Executed successfully in the validation environment · needs numpy, scipy, statsmodels

import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
import statsmodels.api as sm
n=100
x=rng.normal(size=n); z=rng.normal(size=n); y=1+.5*x+.3*z+rng.normal(size=n)
X=sm.add_constant(np.column_stack([x,z])); fit=sm.OLS(y,X).fit(); reduced=sm.OLS(y,X[:,:2]).fit()
print(fit.outlier_test(method="bonf",alpha=.05))
Output
[[-0.07906113  0.93714857  1.        ]
 [ 0.28780623  0.77411547  1.        ]
 [ 0.15522711  0.87696819  1.        ]
 [-0.07459399  0.94069297  1.        ]
 [ 0.24900449  0.80388927  1.        ]
 [ 0.86448778  0.38947498  1.        ]
 [-0.59956994  0.55020537  1.        ]
 [ 0.71279547  0.47770133  1.        ]
 [ 0.59761317  0.55150518  1.        ]
 [ 0.13034785  0.89656397  1.        ]
 [-0.70781303  0.48077631  1.        ]
 [ 0.00512182  0.99592402  1.        ]
 [ 0.77467191  0.4404374   1.        ]
 [-1.23953051  0.21817072  1.        ]
 [-0.05456274  0.95660021  1.        ]
 [ 0.16773237  0.86714667  1.        ]
 [-0.85167162  0.39651593  1.        ]
 [-0.68427711  0.49544878  1.        ]
 [-1.56874082  0.11999873  1.        ]
 [-1.08132309  0.28226229  1.        ]
 [-1.51625158  0.13274177  1.        ]
 [-0.81026461  0.41979214  1.        ]
 [-0.71578837  0.47585949  1.        ]
 [-0.53211713  0.59587424  1.        ]
 [ 0.2963355   0.767614    1.        ]
 [-0.28098749  0.7793247   1.        ]
 [-0.76449542  0.44644718  1.        ]
 [-0.76797029  0.44438977  1.        ]
 [-1.19430493  0.23530129  1.        ]
 [-0.41665093  0.67786389  1.        ]
 [-0.45127705  0.65280766  1.        ]
 [ 1.34313182  0.18239603  1.        ]
 [ 1.47290382  0.14404818  1.        ]
 [ 1.17238507  0.24394361  1.        ]
 [ 2.03435981  0.04467357  1.        ]
 [-1.18242906  0.23995586  1.        ]
 [ 0.68840986  0.49285494  1.        ]
 [ 0.87427235  0.38415186  1.        ]
 [ 0.24095467  0.81010412  1.        ]
 [ 1.78952211  0.07668404  1.        ]
 [ 2.67240751  0.00884914  0.88491389]
 [ 0.78561536  0.43402757  1.        ]
 [ 0.61421223  0.54052798  1.        ]
 [-1.31915118  0.1902564   1.        ]
 [-1.37098919  0.17357496  1.        ]
 [ 0.7082379   0.48051367  1.        ]
 [-0.17692588  0.85993935  1.        ]
 [-1.33622352  0.18463493  1.        ]
 [-0.4127391   0.68071812  1.        ]
 [ 0.06791314  0.94599603  1.        ]
 [ 0.62430238  0.53390987  1.        ]
 [-0.28972738  0.77264964  1.        ]
 [-0.33823592  0.735924    1.        ]
 [-0.24865107  0.80416186  1.        ]
 [ 0.18264155  0.85546443  1.        ]
 [-1.4268649   0.15686322  1.        ]
 [ 0.70397787  0.48315066  1.        ]
 [ 1.91086001  0.05900621  1.        ]
 [ 0.67781726  0.49951798  1.        ]
 [-1.45419258  0.1491546   1.        ]
 [ 0.11832661  0.90605611  1.        ]
 [-1.57891745  0.11764451  1.        ]
 [-1.80902198  0.07357763  1.        ]
 [ 0.56546445  0.57307713  1.        ]
 [ 0.30558562  0.76058181  1.        ]
 [-0.97847072  0.33030092  1.        ]
 [-2.11808464  0.03675083  1.        ]
 [-1.32405479  0.18862882  1.        ]
 [ 0.05338357  0.95753723  1.        ]
 [ 0.05505247  0.95621107  1.        ]
 [ 0.74769218  0.45647348  1.        ]
 [ 1.53906904  0.12707718  1.        ]
 [-0.67554485  0.50095369  1.        ]
 [ 0.53495348  0.59391898  1.        ]
 [-0.40300432  0.68784115  1.        ]
 [-0.8163574   0.41631687  1.        ]
 [-0.19760179  0.84377443  1.        ]
 [ 0.86084001  0.39147109  1.        ]
 [-1.22630357  0.2230839   1.        ]
 [ 1.25925641  0.21099096  1.        ]
 [ 1.41430433  0.16050765  1.        ]
 [ 0.04271924  0.96601407  1.        ]
 [ 0.25304906  0.80077139  1.        ]
 [-1.63794345  0.10470724  1.        ]
 [ 2.36652487  0.01996414  1.        ]
 [ 1.08046838  0.28264058  1.        ]
 [ 0.18757963  0.8516021   1.        ]
 [-0.05296272  0.95787167  1.        ]
 [ 0.03618261  0.97121188  1.        ]
 [-0.74559041  0.45773657  1.        ]
 [ 0.15128804  0.88006596  1.        ]
 [-0.95313331  0.34291628  1.        ]
 [ 0.60010434  0.54985066  1.        ]
 [-0.67393543  0.50197187  1.        ]
 [ 0.8030653   0.42392081  1.        ]
 [-0.51851625  0.60529125  1.        ]
 [ 0.04675671  0.96280426  1.        ]
 [ 2.99534271  0.00348762  0.34876215]
 [ 0.78258531  0.43579684  1.        ]
 [ 0.24820554  0.80450554  1.        ]]
R

Validated — Executed successfully in the validation environment · needs car

set.seed(2026)
n <- 100; x <- rnorm(n); z <- rnorm(n); y <- 1+.5*x+.3*z+rnorm(n)
d <- data.frame(y,x,z); fit <- lm(y~x+z,data=d); reduced <- lm(y~x,data=d)
print(car::outlierTest(fit))
Output
No Studentized residuals with Bonferroni p < 0.05
Largest |rstudent|:
    rstudent unadjusted p-value Bonferroni p
22 -3.329334          0.0012359      0.12359

Sources

Statistics guide v4 (historical):
Python: Executed successfully in the validation environment · R: Executed successfully in the validation environment
Reference's record:
Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Unavailable local dependencies: statsmodels. Python: Not run in the reference's review: Unavailable local dependencies: statsmodels. No installation attempted. R: Reviewed but not run: R wasn't available to the reference's authors.

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