Tutorials › Multivariate Statistics (Graduate) › Rank Tests for Several Independent Groups

Ranks and Nonparametric Methods · Tutorial 764 of 975

Rank Tests for Several Independent Groups

Learn how to construct and center pooled multivariate rank scores, test several groups jointly by permutation, and make carefully calibrated pairwise comparisons.

Advanced 11 min read

What You'll Learn

  • Construct pooled spatial ranks and radial rank scores for observations from several groups
  • Explain why nonlinear score transformations may require explicit centering
  • Derive the conditional covariance of group score sums under random relabeling
  • Form and exactly calibrate an omnibus multisample statistic
  • Calculate pairwise follow-up contrasts and account for multiple comparisons
  • State when a rank test supports an interpretation as a test of multivariate location

Why a Multisample Rank Test?

When observations come from several independent groups, the central question may be whether their multivariate locations agree. A classical test built from sample means can be sensitive to tail behavior and unusual observations. A rank test instead bases its evidence on the relative positions of pooled observations. Its calibration can be exact under a common-distribution null, provided group labels are exchangeable conditional on the pooled data.

The construction below begins with spatial ranks, which assign each observation a vector describing its position relative to the pooled sample. It then turns these vectors into scores, sums the scores within groups, and tests whether the group sums are unusually separated under relabeling. The permutation test is a test of equality of distributions under exchangeability. It can be interpreted as a test of location under a common-shape location model, but equality of locations alone does not generally imply exchangeability.

Pooled Ranks and Group Scores

Definition: Let \(X_{gi}\in\mathbb{R}^p\) be observation \(i\) in group \(g\), where \(g=1,\ldots,k\), \(i=1,\ldots,n_g\), and \(N=\sum_{g=1}^k n_g\). For a pooled observation \(X_a\), define its empirical spatial rank by $$ R_a=\frac{1}{N}\sum_{b=1}^N u(X_a-X_b), \qquad u(x)= \begin{cases} x/\|x\|,&x\ne 0,\\ 0,&x=0. \end{cases} $$ A radial score based on a function \(J:[0,1]\to[0,\infty)\) is \(A_a=J(\|R_a\|)R_a/\|R_a\|\) when \(R_a\ne0\), and \(A_a=0\) when \(R_a=0\). The centered pooled score is \(\widetilde A_a=A_a-\bar A\), where \(\bar A=N^{-1}\sum_{b=1}^N A_b\). The group score sum is \(S_g=\sum_{i=1}^{n_g}\widetilde A_{gi}\).

The convention \(u(0)=0\) handles ties in the pairwise differences. Because \(u(x)=-u(-x)\), summing the raw spatial ranks over all pooled observations gives \(\sum_a R_a=0\): each pair contributes equal and opposite terms. But this does not imply that a nonlinear transformation of the ranks also sums to zero. Explicitly centering the scores ensures \(\sum_a\widetilde A_a=0\), and therefore \(\sum_g S_g=0\), for any chosen score function.

The simplest choice is \(J(t)=t\), which gives \(A_a=R_a\). Other choices can emphasize different parts of the rank configuration, but their transformed scores must not be presumed centered unless this is verified. In the exact test below, the scores are calculated from the pooled observations and held fixed while labels are permuted.

Worked Example: Spatial Ranks for Four Pooled Observations

Take four points in \(\mathbb{R}^2\): \((1,0),(0,1),(-1,0),(0,-1)\). Use the identity score \(J(t)=t\), and assign the first two points to group 1 and the last two to group 2.

For \(X_1=(1,0)\), the nonzero unit vectors \(u(X_1-X_b)\), as \(X_b\) runs over the other three points, are \((1,0),(1,-1)/\sqrt{2},(1,1)/\sqrt{2}\). Their sum is \((1+\sqrt{2},0)\). Dividing by \(N=4\) gives \(R_1=c(1,0)\), where \(c=(1+\sqrt{2})/4\). By the square’s symmetry, the other ranks are \(R_2=c(0,1)\), \(R_3=c(-1,0)\), and \(R_4=c(0,-1)\). They sum to zero.

The group sums are \(S_1=c(1,1)\) and \(S_2=-c(1,1)\). For the statistic \(T=\sum_g\|S_g\|^2/n_g\), with \(n_1=n_2=2\), $$ T=\frac{2c^2}{2}+\frac{2c^2}{2}=2c^2 =\frac{(1+\sqrt{2})^2}{8} =\frac{3+2\sqrt{2}}{8}\approx 0.7286. $$ There are \(\binom{4}{2}=6\) ways to assign two points to group 1. The two opposite-point assignments have statistic zero; the other four assignments have statistic \(2c^2\). Thus this observed allocation is tied for the largest statistic, and its upper-tail exact permutation \(p\)-value is \(4/6=2/3\).

An Omnibus Statistic and Its Permutation Calibration

A convenient omnibus statistic is $$ T=\sum_{g=1}^k\frac{\|S_g\|^2}{n_g}. $$ It is nonnegative and increases when centered scores are separated among groups. The division by \(n_g\) keeps the group contributions on a scale that accounts for unequal group sizes. This choice is not a claim that \(T\) has a universal chi-square distribution: its reference distribution is obtained by permuting the labels while holding the pooled observations, scores, and group sizes fixed.

Theorem (finite-sample permutation validity): Suppose that under the null hypothesis the \(N\) observations are independent and identically distributed, and that, conditional on the pooled observations, every allocation of labels with group sizes \(n_1,\ldots,n_k\) is equally likely. Calculate pooled scores without using group labels. For the observed statistic \(T_{\mathrm{obs}}\), define $$ p_{\mathrm{perm}}= \frac{\#\{\text{label allocations with }T\ge T_{\mathrm{obs}}\}} {\binom{N}{n_1,\ldots,n_k}}. $$ Then the test that rejects when \(p_{\mathrm{perm}}\le\alpha\) has conditional type I error at most \(\alpha\), and hence unconditional type I error at most \(\alpha\). This upper-tail test is valid for any fixed score function and any statistic computed consistently over the allocations.

Proof. Condition on the pooled observations, so every score is fixed. Under the null, the observed label allocation is uniform over the \(M=\binom{N}{n_1,\ldots,n_k}\) possible allocations. Order those allocations by their statistic, allowing ties. For any value \(t\), the permutation \(p\)-value assigned to an allocation with statistic \(t\) is the proportion of allocations whose statistic is at least \(t\). The allocations with \(p_{\mathrm{perm}}\le\alpha\) are among the upper-ranked allocations whose total proportion is at most \(\alpha\); ties can only make this test conservative because all allocations tied at a cutoff receive the same tail proportion. Thus the conditional rejection probability is at most \(\alpha\). Averaging that conditional probability over the pooled observations gives the same unconditional bound. \(\square\)

The exchangeability condition is essential. For example, if the groups have different covariance structures under a null that equates only their locations, labels need not be uniformly distributed conditional on the pooled observations. The exact permutation guarantee then does not follow just from equal locations.

What Random Relabeling Does to the Score Sums

A finite-sample covariance calculation helps explain the reference distribution and the role of score centering. Let \(a_1,\ldots,a_N\) denote the fixed centered score vectors, so \(\sum_a a_a=0\), and define their finite-population second-moment matrix by \(C_N=N^{-1}\sum_a a_a a_a^{\mathsf T}\). Under a uniformly random allocation, let \(I_{ag}\) indicate whether pooled observation \(a\) is assigned to group \(g\). Then \(S_g=\sum_a I_{ag}a_a\).

Result: Under uniform allocation with fixed group sizes, $$ \operatorname{Cov}(S_g)=\frac{n_g(N-n_g)}{N-1}C_N, \qquad \operatorname{Cov}(S_g,S_h)=-\frac{n_gn_h}{N-1}C_N \quad(g\ne h). $$

Derivation. Each observation has probability \(n_g/N\) of entering group \(g\). For distinct observations \(a\ne b\), the probability that both enter group \(g\) is \(n_g(n_g-1)/(N(N-1))\). Consequently, $$ E[S_g]=\frac{n_g}{N}\sum_a a_a=0. $$ Using \(\sum_{a\ne b}a_a a_b^{\mathsf T}=-\sum_a a_a a_a^{\mathsf T}\), obtained by expanding \((\sum_a a_a)(\sum_b a_b)^{\mathsf T}=0\), gives $$ E[S_gS_g^{\mathsf T}] =\left\{\frac{n_g}{N}-\frac{n_g(n_g-1)}{N(N-1)}\right\} \sum_a a_a a_a^{\mathsf T} =\frac{n_g(N-n_g)}{N-1}C_N. $$ For \(g\ne h\), the same observation cannot be assigned to both groups, and for \(a\ne b\) the joint assignment probability is \(n_gn_h/(N(N-1))\). Hence $$ E[S_gS_h^{\mathsf T}] =-\frac{n_gn_h}{N(N-1)}\sum_a a_a a_a^{\mathsf T} =-\frac{n_gn_h}{N-1}C_N. $$ Since the score sums have mean zero, these second moments are the stated covariance matrices. \(\square\)

The negative cross-covariance reflects the constraint \(\sum_g S_g=0\): assigning more score in one direction to a group leaves less available for the others. The calculation describes randomization variability; it does not by itself provide a large-sample reference law or replace permutation calibration.

Worked Example: A Three-Group Omnibus Calculation

Suppose six already-computed centered pooled scores are \(a_1=(1,0)\), \(a_2=(-1,0)\), \(a_3=(0,1)\), \(a_4=(0,-1)\), \(a_5=(1,1)\), and \(a_6=(-1,-1)\). Their total is \((0,0)\). Assign \(a_1,a_5\) to group 1, \(a_2,a_3\) to group 2, and \(a_4,a_6\) to group 3; each group has size two.

The group sums are \(S_1=(2,1)\), \(S_2=(-1,1)\), and \(S_3=(-1,-1)\). They sum to zero, as required. Their squared norms are \(5,2,2\), so $$ T=\frac{5}{2}+\frac{2}{2}+\frac{2}{2}=4.5. $$ This is the observed omnibus statistic. To obtain its exact \(p\)-value, enumerate all \(\binom{6}{2,2,2}=90\) allocations of these fixed scores to three labeled groups of size two, compute \(T\) for each, and count the allocations with \(T\ge4.5\), including ties. The displayed group assignment alone does not determine that count.

Pairwise Follow-Up Comparisons

An omnibus rejection indicates evidence that not all groups have the same distribution under the exchangeability null, but it does not identify which groups differ. A simple pairwise contrast uses the difference of average group scores: $$ D_{gh}=\frac{S_g}{n_g}-\frac{S_h}{n_h}, \qquad T_{gh}=\|D_{gh}\|^2. $$ Large \(T_{gh}\) indicates separation in the score-vector means. A pairwise permutation test recalculates this contrast over allocations of the two groups’ labels while holding the score vectors fixed. Under the pairwise null of identical distributions and exchangeable labels within that pair, its upper-tail permutation \(p\)-value is exact by the same finite-allocation argument. When many pairs are tested, adjust the resulting \(p\)-values—for example, with Holm’s procedure—to control family-wise error.

Worked Example: Pairwise Contrasts in the Three-Group Calculation

For the preceding group sums, the average scores are \(\bar A_1=(1,1/2)\), \(\bar A_2=(-1/2,1/2)\), and \(\bar A_3=(-1/2,-1/2)\). The pairwise contrasts and squared lengths are $$ D_{12}=(3/2,0),\quad T_{12}=9/4; \qquad D_{13}=(3/2,1),\quad T_{13}=13/4; \qquad D_{23}=(0,1),\quad T_{23}=1. $$ Thus groups 1 and 3 have the largest observed score-mean separation in this example. These values rank the observed contrasts, but they are not \(p\)-values: each contrast needs its own valid permutation calibration, and the set of pairwise tests needs a multiplicity adjustment if simultaneous conclusions are intended.

Common Pitfall: Assuming Transformed Scores Stay Centered

Antisymmetry guarantees that raw spatial ranks sum to zero, but it does not guarantee the same property after applying a nonlinear radial score. For example, for pooled points \((0,0),(1,0),(0,2)\), the first coordinates of the raw spatial ranks are \(-1/3\), \((1+1/\sqrt{5})/3\), and \(-1/(3\sqrt{5})\). With \(J(t)=t^2\), the score is \(A_a=\|R_a\|R_a\), and the sum of the first coordinates of the transformed scores is $$ \frac{-\sqrt{2}+(1+1/\sqrt{5})\sqrt{2+2/\sqrt{5}}-\sqrt{2+4/\sqrt{5}}/\sqrt{5}}{9}\ne0. $$ The error is to reason that “the ranks sum to zero, so any score transformation also sums to zero.” That implication is false for nonlinear transformations. Subtracting the pooled mean score gives \(\widetilde A_a=A_a-\bar A\), whose total is exactly zero, and group sums formed from these centered scores satisfy \(\sum_g S_g=0\).

A second interpretive caution is that a rank-based omnibus test is not automatically a test of location alone. If the scientific null is equality of locations while group shapes or dispersions may differ, exchangeability can fail. State the sampling model and null that justify the permutation procedure, and interpret pairwise findings as differences in the tested score distributions unless a suitable common-shape location model supports a more specific conclusion.

Check Your Understanding

Use these questions to check both the construction and the conditions behind the test.

  1. Why do the raw pooled spatial ranks sum to zero, and why can a nonlinear radial score transformation break this property?
  2. What does subtracting the pooled mean score guarantee about the sum of the group score vectors?
  3. In the exact omnibus permutation test, which quantities are held fixed and which are reassigned?
  4. State the exchangeability condition that makes the finite-sample permutation \(p\)-value valid.
  5. Why is a large pairwise score-mean contrast not, by itself, evidence of a statistically significant pairwise difference?
  6. What additional concern arises when several pairwise comparisons are reported after an omnibus test?
Clinical Biostats