BCompare groups · Guide test 014
Welch ANOVA
Tests equality of several means without requiring equal group variances.
Do it in CodeSplash
In the app, set it up in Analyze with one of these methods:
- One-way ANOVA (Welch / classic) — Do the means of three or more independent groups differ?
- Table 1 (characteristics by group) — How do the groups compare on their baseline characteristics?
In One-way ANOVA (Welch / classic), choose Test = Welch's ANOVA.
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 · Welch ANOVA
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 = .097).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- precision weight of group i (size over variance)
- the precision-weighted grand mean
- the sum of the weights
The verdict
F(2, 19.90) = 2.63, p = .097
p > α = .050: compatible with H₀
Groups with noisy data get less weight, so one wide group cannot inflate F. Prefer it to the classic F whenever spreads may differ.
- Statistic
- 2.628
- p-value
- 0.0971
Welch ANOVA on Group 1: n = 12; Group 2: n = 12; Group 3: n = 12: F(2, 19.90) = 2.63, p = .097. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: all k independent population means are equal; H1: some differ.
Assumptions
Independent groups with finite variances and enough observations to estimate them. Unequal variances are allowed. Approximation is most defensible for normal or moderately well behaved samples.
Formula
Parameters and notation
wj are inverse mean variance weights; B produces the finite sample adjustment; numerator degrees of freedom are k−1.
Structure of the method
Compute inverse estimated mean-variance weights, a precision-weighted common mean, and a corrected between-group quadratic form. The Welch correction and denominator degrees of freedom depend on group sizes and weight leverage. Evaluate the resulting F reference using fractional degrees of freedom rather than rounding them.
Estimated and nuisance parameters
Estimate each group mean, variance, and its resulting precision weight. The weighted common mean is a null comparison construct and generally differs from the sample-size-weighted grand mean. The number of groups and the equality-of-means restriction define the tested subspace, not an optimization-selected cluster count.
Settings and design choices
Choose alpha, the mean estimand, a prespecified transformation if needed, and subsequent unequal-variance contrasts. Solver tuning is unnecessary for the closed-form statistic. If robust trimming is desired, use its proper Winsorized-variance extension and explicitly change the estimand rather than silently trimming then applying this formula.
Fitting and adaptation
Recompute all group weights, the common mean, and degrees of freedom when samples change. Refitting is statistical recalculation rather than neural fine-tuning. A simulation-based calibration should reproduce group-specific null variances and sample allocation; unrestricted pooled permutation is not generally exact when group distributions differ under equal means.
Sensitivity and robustness
Small noisy groups may produce uncertain precision estimates, and zero variance causes singular weighting. Severe skew or heavy tails can degrade the F approximation even though variances are allowed to differ. Report group summaries and intervals; omnibus rejection alone does not establish monotonicity or pairwise significance.
How to use and calibrate
Compute FW and compare with Fk−1,ν2. If individual group differences are needed, use contrasts that also allow unequal variances, such as Games–Howell for pairwise comparisons.
Example application
Compare mean response across four independent groups with markedly different standard deviations and sample sizes.
Interpretation and pitfalls
Watch out
Tiny or zero variance groups can dominate inverse variance weighting. This is not a robust outlier method and does not address dependent observations.
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(__import__("statsmodels.stats.oneway",fromlist=["anova_oneway"]).anova_oneway(groups,use_var="unequal"))
Output
AnovaResult(statistic=np.float64(11.781776709790458), pvalue=np.float64(0.00011085753537703958), df=(2.0, np.float64(36.825494297940246)), df_num=2.0, df_denom=np.float64(36.825494297940246), nobs_total=np.float64(60.0), n_groups=3, means=array([-0.09684371, 0.61021021, 1.38121647]), nobs=array([20., 20., 20.]), vars_=array([0.54821158, 0.81067911, 1.38385309]), use_var='unequal', welch_correction=True, df2=None, df_num2=None, pvalue2=None)
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(oneway.test(value~group,d,var.equal=FALSE))
Output
One-way analysis of means (not assuming equal variances) data: value and group F = 7.9191, num df = 2.00, denom df = 37.82, p-value = 0.001341
Sources
- R stats — R stats · oneway.teststat.ethz.ch
- oneway.teststat.ethz.ch
- Statistics guide v4 (historical):
- Python: Executed successfully in the validation environment · R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Unavailable local dependencies: statsmodels. Python: Not run in the reference's review: Unavailable local dependencies: statsmodels. No installation attempted. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 014, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT014.