BCompare groups · Guide test 037
Durbin test for incomplete blocks
Extends rank based treatment comparison to balanced incomplete block designs.
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 = Durbin.
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 · Durbin test for incomplete blocks
Your data
Each subject sees 3 of the 7 conditions| Subject | C1 | C2 | C3 | C4 | C5 | C6 | C7 |
|---|---|---|---|---|---|---|---|
| S1 | 0.759 | 0.844 | – | 1.444 | – | – | – |
| S2 | – | −0.014 | 2.671 | – | 1.106 | – | – |
| S3 | – | – | 2.332 | 2.642 | – | 3.161 | – |
| S4 | – | – | – | −0.175 | 0.488 | – | 0.079 |
| S5 | −0.852 | – | – | – | −0.387 | 1.411 | – |
| S6 | – | 0.524 | – | – | – | 2.317 | 3.188 |
| S7 | 0.505 | – | 3.636 | – | – | – | 0.771 |
| S8 | −0.906 | −0.693 | – | 0.021 | – | – | – |
| S9 | – | −3.006 | −0.582 | – | −2.461 | – | – |
| S10 | – | – | 2.082 | 1.560 | – | 1.471 | – |
| S11 | – | – | – | 3.312 | 2.477 | – | 2.306 |
| S12 | 3.942 | – | – | – | 4.557 | 5.592 | – |
14 subjects, each in 3 of 7 conditions (every pair together 2 times) · first 12 of 14 rows
If H₀ were true
- The reference: how χ² 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 = .098).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- sum of within-subject ranks of condition j
- conditions per subject, subjects per condition, conditions
- sum of the squared ranks (handles ties)
The verdict
χ²(6) = 10.71, p = .098
p > α = .050: compatible with H₀
Friedman's test for designs where each subject sees only some conditions, balanced so every pair meets equally often. The F form is usually better calibrated in small designs.
- Statistic
- 10.714
- p-value
- 0.0976
Durbin test for incomplete blocks on 14 subjects, each in 3 of 7 conditions (every pair together 2 times): χ²(6) = 10.71, p = .098. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: treatment effects are equal in a balanced incomplete block design.
Assumptions
Independent blocks; each contains k of t treatments; every treatment occurs r times and each pair co-occurs equally often; randomization/exchangeability within blocks.
Formula
Parameters and notation
b blocks; Rij ranks observed treatments within a block; Rj is a treatment rank sum. The balance relation is bk=tr.
Structure of the method
Rank observed treatments within each incomplete block, accumulate treatment rank sums, and scale their dispersion using the balanced design constants. A chi-square approximation with treatment-count-minus-one degrees of freedom follows the stated design assumptions; small-sample randomization should permute labels only among assignments permitted by the incomplete-block experiment.
Estimated and nuisance parameters
Computed quantities are observed rank sums and their quadratic normalization. Block size, treatment replication count, total blocks, and pairwise concurrence are design constants that must satisfy balanced-incomplete-block relations. They are not estimated nuisance parameters that software can freely substitute when the observed missingness pattern violates balance.
Settings and design choices
Choose alpha, the intended balanced layout, tie convention, and asymptotic or design-based calibration. Check equal block sizes, equal treatment replication, and equal pair concurrence explicitly. A generic missing-value flag is not a hyperparameter that turns an arbitrary repeated-measures dataset into a valid balanced incomplete-block design.
Fitting and adaptation
After a missing measurement or dropout, re-audit the actual incidence matrix before recalculating the test. If balance is lost, use an appropriate incomplete-block method such as Skillings–Mack when its assumptions apply. Adaptation means changing the design-aware inferential procedure, not plugging revised counts into an unchanged formula.
Sensitivity and robustness
Some implementations do not enforce every balance condition. Extensive ties alter within-block rank variability, while disconnected treatment comparisons prevent a common global comparison. The tiny supplied three-block fixture illustrates the incidence layout but offers very coarse small-sample information; its asymptotic p-value should not be presented as an exact randomization probability.
How to use and calibrate
Compare T with χ²t−1 approximately; a design respecting randomization distribution is preferable for small designs.
Example application
Compare products when each assessor can evaluate only a balanced subset.
Interpretation and pitfalls
Watch out
Arbitrary missing repeated measurements do not form a balanced incomplete design. Some software does not check balance.
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 incomplete block example: every treatment and treatment pair is represented equally; NA means an unobserved cell.
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"""
b <- matrix(c(1,2,NA,NA,3,4,5,NA,6),3,byrow=TRUE)
print(PMCMRplus::durbinTest(b))
"""
# 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
b <- matrix(c(1,2,NA,NA,3,4,5,NA,6),3,byrow=TRUE)
print(PMCMRplus::durbinTest(b))
Sources
- PMCMRplus — PMCMRplus · durbinTestAuthor documentation/source reviewed: PMCMRplus 1.9.12.search.r-project.org
- durbinTestsearch.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 037, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT037.