Skip to content

BCompare groups · Guide test 040

Gore test

Provides a rank based treatment comparison for complete blocks with multiple observations per treatment cell.

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

8
3
3
0.30
0.40
1.2
0.050

Your data

Replicates per cell differ
SubjectConditiony
S1C10.744
S1C10.055
S1C22.065
S1C31.452
S1C32.459
S2C10.510
S2C11.688
S2C11.514
S2C22.064
S2C21.024
S2C2−0.653
S2C30.053

8 subjects × 3 conditions, 55 observations (unequal replicates) · first 12 of 55 rows

If H₀ were true

G = 7.76
  1. The reference: how G varies across samples when H₀ is true (χ² approximation).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .021).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

G=12Nv2(∑idi2qi−(∑idi/qi)2∑i1/qi)G = \dfrac{12N}{v^2}\left(\sum_i \dfrac{d_i^2}{q_i} - \dfrac{\left(\sum_i d_i/q_i\right)^2}{\sum_i 1/q_i}\right)

With your numbers

G=7.76,v−1=2G = 7.76,\qquad v-1 = 2
did_i
condition i's summed pairwise win proportions minus their null mean
qiq_i
Σ 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 H0.

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

Ui=∑a≠i∑j∑h,lh(Xijh,Xajl)nijnajS=12Nv2[∑idi2qi−(∑idi/qi)2∑i1/qi]\begin{gathered}U_i=\sum_{a\ne i}\sum_j\frac{\sum_{h,l}h(X_{ijh},X_{ajl})}{n_{ij}n_{aj}}\\[5pt] S=\frac{12N}{v^2}\left[\sum_i\frac{d_i^2}{q_i}-\frac{(\sum_i d_i/q_i)^2}{\sum_i1/q_i}\right]\end{gathered}

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.

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

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

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.