Skip to content

BCompare groups · Guide test 043

Scheffé test

Provides simultaneous inference for all linear contrasts among group means under the classical ANOVA model.

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

Do it in CodeSplash

In the app, set it up in Analyze with one of these methods:

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

4
10
0.65

Group i has true mean (i − 1) × spread.

1.00
0.050

Your data

Drag a point or use ↑/↓ to change it
Group 1mean 0.49Group 2mean 0.88Group 3mean 1.23Group 4mean 1.73

If H₀ were true

F = 2.36
  1. The reference: how F varies across samples when H₀ is true.
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .088).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The whole family

PairDifference in means with 95% simultaneous intervalpp 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

Fij=(xˉi−xˉj)2(k−1) MSE(1/ni+1/nj)∼Fk−1, N−kF_{ij}=\dfrac{(\bar x_i-\bar x_j)^2}{(k-1)\,\mathrm{MSE}(1/n_i+1/n_j)} \sim F_{k-1,\,N-k}

With your numbers

F=2.36,padj=0.09F = 2.36,\qquad p_{adj} = 0.09
k−1k-1
numerator df: every contrast, not only pairs, is protected
MSE\mathrm{MSE}
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 H0.

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

Fc=(∑jcjxˉj)2(k−1)MSE∑jcj2/nj∑jcj=0\begin{gathered}F_c=\frac{(\sum_jc_j\bar x_j)^2}{(k-1)\mathrm{MSE}\sum_jc_j^2/n_j}\\[5pt] \sum_jc_j=0\end{gathered}

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.

Python · invokes R

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()
R

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

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.