BCompare groups · Guide test 013
Classical one way ANOVA F test
Tests equality of several independent group means under a common error variance.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- One-way ANOVA (Welch / classic) — Do the means of three or more independent groups differ?
In One-way ANOVA (Welch / classic), choose Test = Classic F test.
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 · Classical one-way ANOVA F 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 = .060).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- between-group sum of squares: how far group means sit from the grand mean
- within-group sum of squares: the noise around each group mean
- number of groups
- total sample size
The verdict
F(2, 33) = 3.07, p = .060, η² = 0.16
p > α = .050: compatible with H₀
Effect size: eta squared η² = 0.157
F compares the variation between group means to the variation within groups. A large F says the means are more spread out than noise alone would make them; it does not say which ones differ.
- Statistic
- 3.066
- p-value
- 0.0601
Classical one-way ANOVA F test on Group 1: n = 12; Group 2: n = 12; Group 3: n = 12: F(2, 33) = 3.07, p = .060, η² = 0.16. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: μ1=⋯=μk; H1: at least one mean differs.
Assumptions
Independent errors, approximately normal within groups for exact small sample inference, common error variance, and an appropriate independent groups design.
Formula
Parameters and notation
k is number of groups; N=Σnj; x̄ is the grand mean weighted by group size; numerator and denominator are between and within group mean squares.
Structure of the method
A one-factor linear model partitions variation into weighted between-group and within-group sums of squares. Their mean-square ratio follows an exact F law under independent Gaussian common-variance errors. The omnibus statistic tests a mean-contrast subspace; it does not identify which particular group pairs differ.
Estimated and nuisance parameters
Estimate each group mean and one pooled residual variance. The grand mean is weighted by sample sizes, not an unweighted mean of group means when sizes differ. Group count and sample allocation fix numerator and denominator degrees of freedom; they are experimental-design inputs rather than fitted hyperparameters.
Settings and design choices
Prespecify factor levels, alpha, transformation, and planned follow-up contrast family. Decide whether the scientific question is omnibus or a small number of targeted contrasts. An omnibus gate is not required by every valid simultaneous procedure and does not automatically justify arbitrary unadjusted follow-up searches.
Fitting and adaptation
Refit the linear model after changes in observations or factor coding, checking rank and missingness. For unequal-variance populations use an appropriately specified alternative such as Welch ANOVA. If blocks or repeated measures are present, change the model and denominator error term rather than continuing with an independent-groups F test.
Sensitivity and robustness
Variance heterogeneity and unbalanced sample sizes can combine to distort nominal error rates. Strong skew, extreme observations, and near-zero within-group variance affect the ratio. Balanced designs can be more robust to moderate departures, but balance does not repair dependence, confounding, or incorrect experimental units.
How to use and calibrate
Compute the omnibus F test first if it matches the planned question. To identify differences, use prespecified contrasts or appropriate simultaneous comparisons; report group estimates and uncertainty.
Example application
Test whether three production settings have equal average strength, then use Tukey comparisons for all pairs if that is the analysis plan.
Interpretation and pitfalls
Watch out
An omnibus rejection does not say every mean differs. Heteroskedasticity can invalidate the reference; repeated measurements require a different model. A normality pretest is not a substitute for checking the design.
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
Omnibus test across independent groups; use the model assumptions in this entry and plan multiplicity-adjusted follow-up comparisons.
Validated — Executed successfully in the validation environment · needs numpy, scipy
import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
groups = [rng.normal(m,1,20) for m in (0,.4,.8)]
print(stats.f_oneway(*groups))
Output
F_onewayResult(statistic=np.float64(11.955319461826035), pvalue=np.float64(4.616075599352458e-05))
Validated — Executed successfully in the validation environment · needs Base/standard library
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(summary(aov(value~group,d)))
Output
Df Sum Sq Mean Sq F value Pr(>F) group 2 14.26 7.129 8.674 0.000514 *** Residuals 57 46.85 0.822 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Sources
- SciPy classical and Welch ANOVAdocs.scipy.org
- scipy.stats.f_onewaydocs.scipy.org
- Statistics guide v4 (historical):
- R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: executed · R: not executed (Rscript unavailable). Python: Ran in the reference's review, on this exact code. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 013, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT013.