BCompare groups · Guide test 039
Mack–Skillings test
Tests treatment effects in block designs with multiple observations per 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 = 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
Your data
Every cell has the same replicates| Subject | Condition | y |
|---|---|---|
| S1 | C1 | 0.398 |
| S1 | C1 | −0.089 |
| S1 | C2 | 0.711 |
| S1 | C2 | 3.137 |
| S1 | C3 | 1.572 |
| S1 | C3 | −0.552 |
| S2 | C1 | 0.952 |
| S2 | C1 | −0.087 |
| S2 | C2 | −0.666 |
| S2 | C2 | 0.002 |
| S2 | C3 | −1.435 |
| S2 | C3 | −0.228 |
6 subjects × 3 conditions, 36 observations (2 per cell) · first 12 of 36 rows
If H₀ were true
- The reference: how MS 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 = .164).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- condition j's within-subject ranks summed and divided by c
- replicates per cell
- 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 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
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.
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
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
- NSM3 — NSM3 · pMackSkilAuthor documentation/source reviewed: NSM3 1.20.search.r-project.org
- pMackSkilsearch.r-project.org
- 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.