BCompare groups · Guide test 040
Gore test
Provides a rank based treatment comparison for complete blocks with multiple observations per treatment cell.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Friedman test (repeated measures, ranks) — Do three or more conditions measured on the same subjects differ in location?
In Friedman test (repeated measures, ranks), choose Test = Gore.
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 · Gore test
Your data
Replicates per cell differ| Subject | Condition | y |
|---|---|---|
| S1 | C1 | 0.744 |
| S1 | C1 | 0.055 |
| S1 | C2 | 2.065 |
| S1 | C3 | 1.452 |
| S1 | C3 | 2.459 |
| S2 | C1 | 0.510 |
| S2 | C1 | 1.688 |
| S2 | C1 | 1.514 |
| S2 | C2 | 2.064 |
| S2 | C2 | 1.024 |
| S2 | C2 | −0.653 |
| S2 | C3 | 0.053 |
8 subjects × 3 conditions, 55 observations (unequal replicates) · first 12 of 55 rows
If H₀ were true
- The reference: how G varies across samples when H₀ is true (χ² approximation).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .021).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- condition i's summed pairwise win proportions minus their null mean
- Σ over subjects of N / n_ij (weights for unequal cells)
The verdict
G(2) = 7.76, p = .021
p ≤ α = .050: reject H₀
Generalizes Friedman to unbalanced replicates through within-subject Mann–Whitney win proportions. The χ² approximation needs a fair number of subjects.
- Statistic
- 7.762
- p-value
- 0.0206
Gore test on 8 subjects × 3 conditions, 55 observations (unequal replicates): G(2) = 7.76, p = .021. The p-value is below α = .050, so the data are hard to reconcile with H₀.
Question and hypotheses
H0: equal treatment main effects in an unbalanced replicated block layout.
Assumptions
Independent observations under the block model, adequate cell sizes, all treatment/block cells represented, and no confounding treatment by block interaction.
Formula
Parameters and notation
h(x,y)=I(x>y)+½I(x=y); v treatments, b blocks; N total observations; qi=Σj N/nij; di=Ui−(v−1)b/2.
Structure of the method
Within every block, compute normalized cross-treatment pairwise comparisons, combine these across blocks, and form Gore's weighted quadratic main-effect statistic. Cell counts determine the variance-normalizing terms. The cited implementation uses an asymptotic chi-square reference and a complete treatment-by-block layout that may have unequal replication within its represented cells.
Estimated and nuisance parameters
Computed quantities include pairwise placement averages, treatment score deviations, total observations, and inverse-cell-size weights. Cell counts and block/treatment labels encode the design. No common raw-data residual variance is fitted, but the method still relies on the stated block model and an interpretable treatment main effect.
Settings and design choices
Specify alpha, block definition, treatment factor, tie convention, and the eligible cell structure. Do not choose blocks by sorting outcomes. A numeric tolerance for equal measurements should be grounded in recording precision. If a simulation reference is used, reproduce the original unequal cell sizes and the null's allowed exchangeability.
Fitting and adaptation
Recompute placement averages and all size-dependent normalization after observations are added or removed. Verify that every required cell remains represented. For substantial treatment-by-block interaction, consider modeling conditional treatment effects instead of summarizing everything with one main-effect rank statistic whose interpretation assumes a compatible block structure.
Sensitivity and robustness
Sparse cells can create highly variable normalized placements and disproportionately affect inverse-size terms. Correlated subsamples, missing cells, and interaction confounding are not repaired by ranks. The supplied example uses unequal replication after deleting a few rows but retains all cells; it should not be generalized to arbitrary incomplete-block data.
How to use and calibrate
Compare S with χ²v−1 asymptotically. Use the cited implementation for its sampling model and tie conventions.
Example application
Compare crop varieties across soil blocks with unequal numbers of plots per cell.
Interpretation and pitfalls
Watch out
This is a specific main effect rank procedure, not a general replacement for every unbalanced factorial model.
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
Replicated, unbalanced complete randomized block example; every block-treatment cell retains at least one observation.
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<-expand.grid(block=factor(1:6),group=factor(1:3),rep=1:2);d$y<-rnorm(nrow(d));d<-d[-c(2,8,15),]
print(PMCMRplus::goreTest(d$y,d$group,d$block))
"""
# 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<-expand.grid(block=factor(1:6),group=factor(1:3),rep=1:2);d$y<-rnorm(nrow(d));d<-d[-c(2,8,15),]
print(PMCMRplus::goreTest(d$y,d$group,d$block))
Sources
- PMCMRplus — PMCMRplus · goreTestAuthor documentation/source reviewed: PMCMRplus 1.9.12.search.r-project.org
- goreTestsearch.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 040, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT040.