Chip Foundry Services Request Assessment

Friedman Test

The Friedman test compares three or more conditions measured on the same units, or on matched blocks, using ranks. It is the rank-based counterpart of repeated-measures ANOVA and an extension of the Wilcoxon signed-rank test beyond two conditions. By ranking within each unit, it removes unit-to-unit differences, so each wafer, lot or operator acts as its own control.

The sequence:

Same units under k conditions
repeated measures or matched blocks
Rank inside each blockeach wafer is its own control
Rank the k values in every row
1 to k, ties share the average
Sum ranks per condition
R1, ..., Rk
Friedman Q statistic
large Q means conditions rank consistently apart
Significant Q: which conditions differ?
pairwise Wilcoxon or Nemenyi follow-up, adjusted

The statistic. With $b$ blocks and $k$ conditions, rank the $k$ values within each block from $1$ to $k$, and let $R_j$ be the sum of the ranks of condition $j$ across all blocks. If the conditions do not differ, every condition has the same expected rank sum, $b(k+1)/2$. The Friedman statistic measures how far the rank sums stray from it:

$$Q=\frac{12}{bk(k+1)}\sum_{j=1}^{k}R_j^2-3b(k+1)$$

For reasonably many blocks, $Q$ is approximately chi-square with $k-1$ degrees of freedom under the null hypothesis. Ties within a block share average ranks, and software applies a correction.

Worked example. Six wafers are each measured under three chamber conditions, and the picture shows each wafer's ranks. In every wafer but one, condition 1 is lowest, condition 2 is in the middle and condition 3 is highest. Wafer 3 swaps the first two. The rank sums are $R_1=7$, $R_2=11$, $R_3=18$, against an expected $12$ each, and they add up to $36=bk(k+1)/2$. Then:

$$Q=\frac{12}{6\cdot3\cdot4}\left(7^2+11^2+18^2\right)-3\cdot6\cdot4=\frac{12}{72}(494)-72\approx10.33$$

On $k-1=2$ degrees of freedom the $5\%$ critical value is $5.991$ and the chi-square approximation gives $p=0.0057$, matching scipy.

Friedman ranks within each wafer, then adds up the columns 6 wafers measured in 3 chamber conditions; ranking inside a row removes wafer-to-wafer differences Condition 1 Condition 2 Condition 3 Wafer 1 1 2 3 Wafer 2 1 2 3 Wafer 3 2 1 3 Wafer 4 1 2 3 Wafer 5 1 2 3 Wafer 6 1 2 3 Rank sums 7 11 18 expected 12 each Q = 10.33 on 2 df chi-square p = 0.0057 exact p = 78 / 46656 = 0.0017 condition 3 ranked highest in all 6 wafers; condition 1 lowest in 5 1 = lowest, 3 = highest

Exact p-value for small samples. With only six blocks the approximation is rough. Each block can be ranked in $3!=6$ ways, so there are $6^6=46{,}656$ equally likely rank tables under the null. Exactly $78$ of them give $Q\ge10.33$, so the exact p-value is $78/46656\approx0.0017$, smaller than the approximate $0.0057$. Use an exact or permutation version when $b$ is small.

Agreement and effect size. Kendall's coefficient of concordance rescales the statistic to the range from $0$ to $1$, where $1$ means every block ranks the conditions identically:

$$W=\frac{Q}{b(k-1)}=\frac{10.33}{6\cdot2}\approx0.861$$

A value of $0.861$ says the wafers agree strongly on the ordering of the conditions, not just that one condition is higher on average.

After a significant result. Friedman reports that some condition differs. To locate it, compare pairs of conditions with the Wilcoxon signed-rank test, or Nemenyi's test, and adjust for the number of comparisons with Holm or Bonferroni. In this example condition 3 is highest in all six wafers.

Reading the result.

  • Blocking matters: the test is valid only when the same unit or a matched block provides the value for every condition. Independent groups need Kruskal-Wallis.
  • Complete blocks: every block needs a value for every condition. A missing value usually means dropping the block or using a model for incomplete data.
  • What it detects: consistent differences in ordering within blocks. It ignores how large the differences are, so it can miss a shift that is real but inconsistent across blocks.
  • Power: when the data are close to normal, repeated-measures ANOVA is more powerful. Friedman is the safer choice with outliers, ordinal ratings or small samples.
  • Two conditions: with $k=2$ it reduces to the sign test, which is why the Wilcoxon signed-rank test, using sizes too, is preferred for pairs.

Read the Friedman test as a ranking tally in which each unit votes on the order of the conditions: the more uniformly the votes agree, the larger $Q$ becomes.