Skip to content

ADescribe · Guide test 102

Cochran C test

Tests whether the largest of several normally distributed groups’ variance estimates is unusually large.

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

Do it in CodeSplash

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

In Equal spread tests, choose Test = Cochran's C.

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 · Cochran C test

4
10
0.00

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

2.20
0.050

Your data

Drag a point or use ↑/↓ to change it
Group 1mean 0.49Group 2mean 0.30Group 3mean −0.11Group 4mean −0.48

If H₀ were true

C = 0.38
  1. The reference: how C 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).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .406).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

C=max⁡jsj2∑jsj2C=\dfrac{\max_j s_j^2}{\sum_j s_j^2}

With your numbers

C=4.2211.02=0.38C = \dfrac{4.22}{11.02} = 0.38
sj2s_j^2
each group's sample variance
kk
number of groups

The verdict

C = 0.38, p = .406

p > α = .050: compatible with H₀

Targets a single outlying variance. The reference is simulated from normal data with these group sizes; like Bartlett's test it is sensitive to non-normal tails.

Statistic
0.383
p-value
0.4057
Cochran C test on Group 1: n = 10; Group 2: n = 10; Group 3: n = 10; Group 4: n = 10: C = 0.38, p = .406. The p-value is above α = .050, so the data are compatible with H0.

Cochran C test on Group 1: n = 10; Group 2: n = 10; Group 3: n = 10; Group 4: n = 10: C = 0.38, p = .406. The p-value is above α = .050, so the data are compatible with H₀.

Question and hypotheses

H0: k normal groups have equal variances; H1: one is unusually large.

Assumptions

Independent normal groups, classically equal group sizes n. A one-sided largest-variance alternative is intended.

Formula

C=max⁡jsj2∑jsj2C=\frac{\max_j s_j^2}{\sum_j s_j^2}

Parameters and notation

k groups; each variance has ν=n−1 degrees of freedom in the balanced version.

Structure of the method

Compute all group sample variances, select the largest, and divide it by their sum. The null distribution accounts for selecting the maximum among k normal-group variances; it is not the distribution of one prespecified group variance or an ordinary two-sample F ratio.

Estimated and nuisance parameters

Estimate group means and unbiased variances. In the classical balanced design, each variance has the same n-1 degrees of freedom; the unknown common variance scale cancels. The group attaining the maximum is selected from the data and must be included in calibration.

Settings and design choices

Prespecify the largest-variance alternative, group count, equal sample-size design, and critical-value or simulation method. Some software also provides a smallest-variance variant, which is a different tail target. Do not silently use balanced critical values for unequal group sizes.

Fitting and adaptation

New groups or sample sizes require a new null reference, not just a recomputed ratio. Simulation under a common normal variance should reproduce every group size and the maximum selection step. There is no fine-tuning; repeated deletion and retesting of extreme groups requires its own error control.

Sensitivity and robustness

Heavy tails, outliers, and nonnormality can create unusually large sample variances without the intended Gaussian variance mechanism. Very small within-group sample sizes give unstable maxima. Report all group variances and retain the distinction from Cochran’s matched-binary Q and heterogeneity Q.

How to use and calibrate

Use Cochran C critical values or a properly simulated normal null distribution for the specified design.

Example application

Detect one laboratory with anomalously high variability in a balanced precision study.

Interpretation and pitfalls

Watch out

This is neither Cochran Q binary nor meta-analysis Q. Unequal sample sizes need a justified extension.

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.

Python · invokes R

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

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::cochranTest(value~group,data=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 102, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT102.