ADescribe · Guide test 103
Hartley F max test
Tests variance homogeneity using the ratio of largest to smallest sample variance, classically for equal group sizes.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Equal spread tests — Do two or more groups have the same spread?
In Equal spread tests, choose Test = Hartley F-max.
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 · Hartley F max 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_max varies across samples when H₀ is true, simulated: 9999 normal-theory replicates (group sizes 10, 10, 10, 10) (simulated normal-theory null on the shared Wichmann–Hill stream).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .114).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- each group's sample variance
- groups and group size
The verdict
F_max = 4.93, p = .114
p > α = .050: compatible with H₀
The simplest variance-homogeneity check, designed for equal group sizes and normal data; the reference is simulated under normality for these sizes.
- Statistic
- 4.925
- p-value
- 0.1137
Hartley F max test on Group 1: n = 10; Group 2: n = 10; Group 3: n = 10; Group 4: n = 10: F_max = 4.93, p = .114. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: k normal populations have equal variances.
Assumptions
Independent normal groups with equal sample sizes for standard Hartley tables.
Formula
Parameters and notation
k group count and ν=n−1 determine the null distribution.
Structure of the method
Compute the ratio of the largest to the smallest sample variance across all groups. Calibration uses the distribution of both selected extremes under equal normal variances, with group count and variance degrees of freedom determining the standard balanced-design reference.
Estimated and nuisance parameters
Estimate a mean and variance within each group; common scale cancels from the ratio. Both numerator and denominator groups are selected after observing variances. Therefore ordinary F degrees of freedom for just those two groups do not account for the complete selection procedure.
Settings and design choices
Fix group definitions, balanced sample sizes, significance level, and the Hartley critical-value or simulation algorithm. An unbalanced extension must be justified explicitly rather than substituting an average sample size. Preplanned grouping is essential because splitting or combining groups changes the reference.
Fitting and adaptation
Recompute the reference when the number of groups or their sample sizes changes. A null simulation generates every group under equal normal variance and recalculates the max/min ratio. No neural fine-tuning applies, and selecting only the most discrepant pair before testing is not equivalent.
Sensitivity and robustness
A nearly zero minimum variance makes the statistic enormous or undefined. Nonnormality, rounding, and tiny group sizes can dominate the ratio. The maximum-to-minimum summary hides intermediate groups; inspect the full variance pattern and report whether the balanced Gaussian assumptions are credible.
How to use and calibrate
Use the Hartley Fmax distribution or simulation; do not use an ordinary two-group F reference when k>2.
Example application
Screen variance homogeneity in a balanced normal experiment.
Interpretation and pitfalls
Watch out
Sensitive to nonnormality and to very small minimum variances. Standard critical values do not cover arbitrary unbalanced groups.
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
Balanced normal groups. Cochran uses the largest variance divided by their sum; Hartley uses largest/smallest.
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)
d <- data.frame(value=c(rnorm(20),rnorm(20,.4),rnorm(20,.8)), group=factor(rep(c("A","B","C"),each=20)))
print(PMCMRplus::hartleyTest(value~group,data=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 PMCMRplus
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(PMCMRplus::hartleyTest(value~group,data=d))
Sources
- PMCMRplus — PMCMRplus · hartleyTestAuthor documentation/source reviewed: PMCMRplus 1.9.12.search.r-project.org
- hartleyTestsearch.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 103, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT103.