BCompare groups · Guide test 043
Scheffé test
Provides simultaneous inference for all linear contrasts among group means under the classical ANOVA model.
Do it in CodeSplash
In the app, set it up in Analyze with one of these methods:
- Factorial ANOVA (two or three between factors) — Do two or more factors, and their interaction, affect the mean of an outcome?
- Pairwise comparisons (Tukey, Games–Howell, Dunnett, Dunn, Steel–Dwass …) — Which groups differ from which?
In One-way ANOVA (Welch / classic), choose Post hoc comparisons = Scheffé. In Pairwise comparisons (Tukey, Games–Howell, Dunnett, Dunn, Steel–Dwass …), choose Comparison = Scheffé.
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 · Scheffé test
Group i has true mean (i − 1) × spread.
Your data
Drag a point or use ↑/↓ to change itIf H₀ were true
- The reference: how F varies across samples when H₀ is true.
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .088).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The whole family
| Pair | Difference in means with 95% simultaneous interval | p | p adj. |
|---|---|---|---|
| .412 | .875 | ||
| .120 | .478 | ||
| .012 | .088 | ||
| .450 | .900 | ||
| .076 | .356 | ||
| .293 | .769 |
6 pairs; adjusted by Scheffé's F. The highlighted row is the one in the reference pane (the most extreme by default).
The formula
With your numbers
- numerator df: every contrast, not only pairs, is protected
- pooled within-group mean square
The verdict
F(3, 36) = 2.36, p = .088, Δ = −1.24
p > α = .050: compatible with H₀
Effect size: Group 1 − Group 4 (difference in means) Δ = −1.239
Protects every possible contrast at once, so for pairs alone it is the most conservative of the family. A pair is significant only if some contrast would be under the F test.
- Statistic
- 2.357
- p-value
- 0.0880
Scheffé test on Group 1: n = 10; Group 2: n = 10; Group 3: n = 10; Group 4: n = 10: F(3, 36) = 2.36, p = .088, Δ = −1.24. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: a specified contrast Σcjμj=0; simultaneous protection covers every contrast.
Assumptions
Independent normal errors with common variance in a one factor model; group sizes may differ. The family of comparisons must be specified.
Formula
Parameters and notation
k groups; residual ν=N−k; coefficients cj define the contrast.
Structure of the method
Fit the classical common-variance model and compare a linear contrast's squared standardized estimate with a dimension-adjusted F critical value. The same bound protects the entire space of linear contrasts among the fixed set of group means, allowing exploratory contrast selection within that model without pretending each contrast was planned.
Estimated and nuisance parameters
Estimate group means and pooled residual variance. Contrast coefficients define a linear combination whose weights sum to zero; group sizes determine its variance. The dimension k-minus-one reflects the full contrast space, not the number of contrasts eventually printed, and remains relevant even when only one exploratory contrast is reported.
Settings and design choices
Set familywise alpha and the underlying group model. Contrast selection within Scheffe's protected linear space is allowed, but outcome-driven changes to the model, included groups, response transformation, or endpoint family are not automatically protected. For a small prespecified set, a narrower simultaneous method may be more efficient.
Fitting and adaptation
Refit means and residual variance after changes to the dataset and recalculate the same full-space critical value. If covariates are added, define the estimable contrast space and its covariance in the revised model. Adaptation concerns model and contrast geometry, not training epochs or neural fine-tuning.
Sensitivity and robustness
The broad all-contrast guarantee can yield wide intervals and low power for simple pairwise questions. Heteroskedasticity, dependence, rank deficiency, and sparse groups can invalidate or complicate the classical derivation. The guarantee concerns linear contrasts only; nonlinear ratios or a selected subgroup defined from outcomes require separate methods.
How to use and calibrate
Reject when Fc>Fk−1,ν; form simultaneous bounds using √[(k−1)Fcritical].
Example application
Investigate an unplanned contrast between the average of two treatments and a third.
Interpretation and pitfalls
Watch out
Broad protection can be conservative for a small set of planned comparisons. This does not cover arbitrary nonlinear comparisons.
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
Scheffé protects all linear contrasts; displayed pairwise contrasts are a subset of that family.
Not run — Python launcher syntax checked; R backend runtime not verified · needs Python standard library + Rscript; R packages: DescTools
# 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)
d <- data.frame(value=c(rnorm(20),rnorm(20,.4),rnorm(20,.8)), group=factor(rep(c("A","B","C"),each=20)))
print(DescTools::ScheffeTest(aov(value~group,d)))
"""
# 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 DescTools
set.seed(2026)
d <- data.frame(value=c(rnorm(20),rnorm(20,.4),rnorm(20,.8)), group=factor(rep(c("A","B","C"),each=20)))
print(DescTools::ScheffeTest(aov(value~group,d)))
Sources
- DescTools — DescTools · ScheffeTestAuthor documentation/source reviewed: DescTools 0.99.60.search.r-project.org
- ScheffeTestsearch.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 043, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT043.