Skip to content

BCompare groups · Guide test 013

Classical one way ANOVA F test

Tests equality of several independent group means under a common error variance.

Runs in CodeSplashPython example validatedR example validated

Do it in CodeSplash

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

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

3
12
0.50

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

1.00
0.050

Your data

Drag a point or use ↑/↓ to change it
Group 1 · n = 12 · mean −0.08Group 2 · n = 12 · mean 0.83Group 3 · n = 12 · mean 1.13

If H₀ were true

F = 3.07
  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 = .060).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

F=SSB/(k−1)SSW/(N−k)F = \dfrac{SS_B/(k-1)}{SS_W/(N-k)}

With your numbers

F=9.60/251.66/33=3.07F = \dfrac{9.60/2}{51.66/33} = 3.07
SSBSS_B
between-group sum of squares: how far group means sit from the grand mean
SSWSS_W
within-group sum of squares: the noise around each group mean
kk
number of groups
NN
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 H0.

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

F=∑j=1knj(xˉj−xˉ)2/(k−1)∑j∑i(xij−xˉj)2/(N−k)∼Fk−1,N−kF=\frac{\sum_{j=1}^k n_j(\bar x_j-\bar x)^2/(k-1)}{\sum_j\sum_i(x_{ij}-\bar x_j)^2/(N-k)}\sim F_{k-1,N-k}

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.

Python · native

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

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

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.