Skip to content

BCompare groups · Guide test 039

Mack–Skillings test

Tests treatment effects in block designs with multiple observations per cell.

Runs in CodeSplashPython example validatedR example validated

Do it in CodeSplash

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

In Friedman test (repeated measures, ranks), choose Test = Mack–Skillings.

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 · Mack–Skillings test

6
3
2
0.40
1.2
0.050

Your data

Every cell has the same replicates
SubjectConditiony
S1C10.398
S1C1−0.089
S1C20.711
S1C23.137
S1C31.572
S1C3−0.552
S2C10.952
S2C1−0.087
S2C2−0.666
S2C20.002
S2C3−1.435
S2C3−0.228

6 subjects × 3 conditions, 36 observations (2 per cell) · first 12 of 36 rows

If H₀ were true

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

The formula

MS=1kλ∑j(Sj−b(kc+1)2)2MS = \dfrac{1}{k\lambda}\sum_j\left(S_j - \dfrac{b(kc+1)}{2}\right)^2

With your numbers

MS=3.62,k−1=2MS = 3.62,\qquad k-1 = 2
SjS_j
condition j's within-subject ranks summed and divided by c
cc
replicates per cell
λ\lambda
the tie-corrected rank variance

The verdict

MS(2) = 3.62, p = .164

p > α = .050: compatible with H₀

Friedman with replicates: ranks are taken within each subject over all of its observations. It needs the same number of replicates in every subject × condition cell.

Statistic
3.619
p-value
0.1637
Mack–Skillings test on 6 subjects × 3 conditions, 36 observations (2 per cell): MS(2) = 3.62, p = .164. The p-value is above α = .050, so the data are compatible with H0.

Mack–Skillings test on 6 subjects × 3 conditions, 36 observations (2 per cell): MS(2) = 3.62, p = .164. The p-value is above α = .050, so the data are compatible with H₀.

Question and hypotheses

H0: equal treatment effects in complete blocks with c replicated observations per cell.

Assumptions

Independent blocks and exchangeability of observations within a block under the null; balanced replication c for the displayed statistic.

Formula

Sj=c−1∑i=1b∑h=1cRijhMS=12∑jSj2k(N+b)−3(N+b)N=bkc\begin{gathered}S_j=c^{-1}\sum_{i=1}^{b}\sum_{h=1}^{c}R_{ijh}\\[5pt] MS=\frac{12\sum_jS_j^2}{k(N+b)}-3(N+b)\\[5pt] N=bkc\end{gathered}

Parameters and notation

Rank all kc observations jointly within each block. k treatments, b blocks, c replicates per treatment/block.

Structure of the method

Rank all treatment-by-replicate observations jointly inside each block, average rank contributions over the fixed cell replication count, and aggregate treatment totals. The Mack–Skillings quadratic statistic extends complete-block rank comparison to replicated cells. Its null can be enumerated, sampled by Monte Carlo, or approximated by chi-square under a stated balanced design.

Estimated and nuisance parameters

Computed parameters are blockwise ranks and treatment average-rank totals. Block count, treatment count, and equal within-cell replication are fixed design quantities. The displayed formula assumes a common replicate count; an unbalanced array cannot be handled merely by replacing it with an average replication number.

Settings and design choices

Prespecify the randomization unit, alpha, tie convention, exact/Monte Carlo/asymptotic method, and Monte Carlo budget. NSM3 documents distinct calibration choices. Technical subsamples of one experimental unit do not become independent replicates simply because they occupy separate positions in the input array.

Fitting and adaptation

Recalculate within-block ranks and totals after correcting cells, preserving the replicate structure. A null permutation must respect which observations were exchangeable in the original experiment. If replication becomes unequal or cells disappear, move to a method derived for that layout rather than forcing the balanced formula to accept it.

Sensitivity and robustness

Ties, small numbers of independent blocks, and within-cell correlation can undermine the reference distribution. Increasing technical replication may add little independent evidence. The supplied custom snippets implement the untied asymptotic statistic on continuous synthetic data; they do not implement NSM3's exact or Monte Carlo options or an additional tie correction.

How to use and calibrate

Use exact or Monte Carlo within block permutations, or χ²k−1 asymptotically; correct for ties when needed.

Example application

Compare manufacturing treatments with several specimens per treatment in every production batch.

Interpretation and pitfalls

Watch out

Replicates must reflect the randomization unit; correlated subsamples are not independent experimental replication.

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 replicated complete blocks: 12 blocks, 3 treatments, 2 replicates per cell. All treatment/replicate observations are ranked together within each block. Uses the untied asymptotic chi-square reference; correlated subsamples are not independent replication.

Python · native

Validated — Executed successfully in the validation environment · needs numpy, scipy

import numpy as np
from scipy import stats
rng=np.random.default_rng(2026)
b,k,c=12,3,2
A=rng.normal(size=(b,k,c)) # block × treatment × replicate
S=np.zeros(k)
for block in A:S+=stats.rankdata(block.ravel()).reshape(k,c).sum(1)/c
N=b*k*c;MS=12*np.sum(S*S)/(k*(N+b))-3*(N+b)
print(MS,k-1,stats.chi2.sf(MS,k-1))
Output
0.095238095238102 2 0.9534969548334735
R

Validated — Executed successfully in the validation environment · needs Base/standard library

set.seed(2026)
b<-12;k<-3;c<-2
A<-array(rnorm(b*k*c),dim=c(c,k,b)) # replicate × treatment × block
S<-numeric(k)
for(i in seq_len(b)) {r<-matrix(rank(A[,,i]),nrow=c,ncol=k);S<-S+colSums(r)/c}
N<-b*k*c;MS<-12*sum(S^2)/(k*(N+b))-3*(N+b)
print(c(statistic=MS,df=k-1,p=pchisq(MS,k-1,lower.tail=FALSE)))
Output
statistic        df         p 
0.1666667 2.0000000 0.9200444

Sources

Statistics guide v4 (historical):
R: Executed successfully in the validation environment
Reference's record:
Edition 2 review: Python: executed · R: not executed (Rscript unavailable). Python: Ran in the reference's review, on this exact code. R: Reviewed but not run: R wasn't available to the reference's authors.

From the CodeSplash statistics guide (v4), entry 039, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT039.