Skip to content

BCompare groups · Guide test 037

Durbin test for incomplete blocks

Extends rank based treatment comparison to balanced incomplete block designs.

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

2
0.25
1.2
0.050

Your data

Each subject sees 3 of the 7 conditions
SubjectC1C2C3C4C5C6C7
S10.7590.844–1.444–––
S2–−0.0142.671–1.106––
S3––2.3322.642–3.161–
S4–––−0.1750.488–0.079
S5−0.852–––−0.3871.411–
S6–0.524–––2.3173.188
S70.505–3.636–––0.771
S8−0.906−0.693–0.021–––
S9–−3.006−0.582–−2.461––
S10––2.0821.560–1.471–
S11–––3.3122.477–2.306
S123.942–––4.5575.592–

14 subjects, each in 3 of 7 conditions (every pair together 2 times) · first 12 of 14 rows

If H₀ were true

χ² = 10.71
  1. The reference: how χ² 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 = .098).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

χD2=(t−1)(∑jRj2−rC)A−C,C=bk(k+1)24\chi^2_D = \dfrac{(t-1)\left(\sum_j R_j^2 - rC\right)}{A - C},\quad C=\dfrac{bk(k+1)^2}{4}

With your numbers

χD2=10.71,t−1=6,F=2.27\chi^2_D = 10.71,\qquad t-1 = 6,\qquad F = 2.27
RjR_j
sum of within-subject ranks of condition j
k, r, tk,\ r,\ t
conditions per subject, subjects per condition, conditions
AA
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 H0.

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

A=∑Rij2, C=bk(k+1)2/4T=t−1A−C(∑j=1tRj2−rC)\begin{gathered}A=\sum R_{ij}^2,\ C=bk(k+1)^2/4\\[5pt] T=\frac{t-1}{A-C}\left(\sum_{j=1}^{t}R_j^2-rC\right)\end{gathered}

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.

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

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

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.