Tutorials › Multivariate Statistics (Graduate) › Empirical Spatial Ranks and Rank Scores

Ranks and Nonparametric Methods · Tutorial 757 of 975

Empirical Spatial Ranks and Rank Scores

Learn to compute empirical spatial ranks, interpret their direction and magnitude, and transform them into rank-score vectors.

Advanced 11 min read

What You'll Learn

  • Define the population spatial distribution function and its empirical version
  • Compute empirical spatial ranks, including when observations coincide
  • Interpret rank direction and magnitude without treating them as distances
  • Prove basic centering, norm-bound, and equivariance properties
  • Construct vector rank scores from a radial score function
  • Recognize common errors in interpreting spatial ranks and scores

From Pairwise Directions to Spatial Ranks

A univariate rank tells us where an observation sits in an ordering. In several dimensions, there is no unique ordering that respects every direction. Spatial ranks instead summarize the directions from the other observations toward a point. They retain directional information while providing a bounded vector that can be transformed into a score for multivariate procedures.

The construction uses the spatial sign: for a nonzero vector, its spatial sign is its direction with length one. The spatial sign covariance and the geometry of spatial signs provide useful background, but a spatial rank averages signs over a reference distribution or sample.

Definition: For \(z\in\mathbb{R}^d\), define the spatial sign \(U(z)=z/\|z\|\) if \(z\ne 0\), and \(U(0)=0\). If \(X\) has distribution \(F\), the spatial distribution function (also called the population spatial rank function) is the vector-valued map $$ R_F(x)=E[U(x-X)],\qquad x\in\mathbb{R}^d. $$ For observations \(\mathbf{x}_1,\ldots,\mathbf{x}_n\), the empirical spatial distribution function is $$ R_n(x)=\frac{1}{n}\sum_{j=1}^n U(x-\mathbf{x}_j). $$ The empirical spatial rank of observation \(\mathbf{x}_i\) is \(R_{ni}=R_n(\mathbf{x}_i)\).

The expectation defining \(R_F\) always exists because \(\|U(x-X)\|\leq 1\). The empirical definition includes the observation itself: its contribution is \(U(0)=0\), and the denominator remains \(n\). This convention makes the empirical function an average over the full empirical distribution. Some sources instead omit the self-comparison and divide by \(n-1\); formulas and bounds then differ by a factor of \(n/(n-1)\).

Direction and Magnitude

Each summand in \(R_n(x)\) points from an observed data point toward \(x\). Thus \(R_n(x)\) points in the average direction of the data relative to \(x\): a positive component indicates a net direction along that coordinate axis, while components may cancel. Its length measures the degree of directional agreement among the vectors being averaged. It is not a distance from \(x\) to the data and does not generally increase in a simple way with distance from the sample center.

At an observed point, the self-comparison is zero, so the other \(n-1\) vectors each have length one unless they also arise from coincident observations. The triangle inequality therefore gives \(\|R_{ni}\|\leq(n-1)/n\). A small rank length can arise when directions largely cancel; a larger length indicates more alignment. Neither quantity alone determines the observation's distance from the data cloud.

Worked Example: Ranks on a Line

Take the one-dimensional observations \(x_1=1\), \(x_2=2\), and \(x_3=4\). In one dimension, each nonzero spatial sign is \(+1\) or \(-1\). For the first observation, $$ R_{n1}=\frac{U(1-1)+U(1-2)+U(1-4)}{3} =\frac{0-1-1}{3}=-\frac{2}{3}. $$

For the second observation, $$ R_{n2}=\frac{U(2-1)+U(2-2)+U(2-4)}{3} =\frac{1+0-1}{3}=0. $$ For the third, $$ R_{n3}=\frac{U(4-1)+U(4-2)+U(4-4)}{3} =\frac{1+1+0}{3}=\frac{2}{3}. $$

The signs indicate that the first observation lies in the net negative direction of the others, while the last lies in the net positive direction. The middle observation's contributions cancel. This is a directional summary, not a rescaled distance: for example, the two gaps in the sample are 1 and 2, but the rank magnitudes of the two endpoints are equal.

Worked Example: A Three-Point Configuration in Two Dimensions

Let \(\mathbf{x}_1=(0,0)\), \(\mathbf{x}_2=(2,0)\), and \(\mathbf{x}_3=(0,2)\). From \(\mathbf{x}_1\), the two nonzero direction vectors are \((-1,0)\) and \((0,-1)\). Hence $$ R_{n1}=\frac{1}{3}(-1,-1)=\left(-\frac13,-\frac13\right), \qquad \|R_{n1}\|=\frac{\sqrt{2}}{3}. $$

At \(\mathbf{x}_2\), the directions toward \(\mathbf{x}_1\) and \(\mathbf{x}_3\) are \((1,0)\) and \((1/\sqrt{2},-1/\sqrt{2})\). Therefore $$ R_{n2}=\frac13\left(1+\frac{1}{\sqrt{2}},-\frac{1}{\sqrt{2}}\right), \qquad \|R_{n2}\|=\frac{\sqrt{2+\sqrt{2}}}{3}. $$

By the corresponding calculation at \(\mathbf{x}_3\), $$ R_{n3}=\frac13\left(-\frac{1}{\sqrt{2}},1+\frac{1}{\sqrt{2}}\right), \qquad \|R_{n3}\|=\frac{\sqrt{2+\sqrt{2}}}{3}. $$ The first rank points toward the lower-left, while the other two point in different directions. Their larger lengths reflect stronger directional agreement, not necessarily greater distance from a center.

Basic Properties and Their Proof

The empirical ranks have useful structural properties that follow directly from their pairwise definition. In the result below, \(\mathbf{Q}\) is any orthogonal \(d\times d\) matrix, so that \(\mathbf{Q}^{\mathsf T}\mathbf{Q}=\mathbf{I}\), and \(\mathbf{a}\in\mathbb{R}^d\) is any fixed translation.

Theorem: For any finite sample in \(\mathbb{R}^d\), empirical spatial ranks satisfy $$ \sum_{i=1}^n R_{ni}=0,\qquad \|R_{ni}\|\leq\frac{n-1}{n}. $$ If every observation is transformed to \(\mathbf{a}+\mathbf{Q}\mathbf{x}_i\), the corresponding ranks are \(\mathbf{Q}R_{ni}\). These statements allow repeated observations.

Proof. First, the spatial sign is odd: \(U(-z)=-U(z)\), including at \(z=0\). Consequently, $$ \sum_{i=1}^n R_{ni} =\frac1n\sum_{i=1}^n\sum_{j=1}^n U(\mathbf{x}_i-\mathbf{x}_j) =\frac1n\sum_{i<j}\bigl\{U(\mathbf{x}_i-\mathbf{x}_j)+U(\mathbf{x}_j-\mathbf{x}_i)\bigr\}=0. $$ For the norm bound, the \(j=i\) term is zero and every other term has norm at most one. The triangle inequality yields $$ \|R_{ni}\| \leq\frac1n\sum_{j\ne i}\|U(\mathbf{x}_i-\mathbf{x}_j)\| \leq\frac{n-1}{n}. $$ This remains true when some of those terms are zero because observations coincide.

For the transformation property, translation cancels in each difference. Orthogonality preserves lengths, so for every \(z\), \(U(\mathbf{Q}z)=\mathbf{Q}U(z)\), including \(z=0\). Thus the transformed rank at observation \(i\) is $$ \frac1n\sum_{j=1}^n U\bigl(\mathbf{Q}(\mathbf{x}_i-\mathbf{x}_j)\bigr) =\mathbf{Q}\left\{\frac1n\sum_{j=1}^n U(\mathbf{x}_i-\mathbf{x}_j)\right\} =\mathbf{Q}R_{ni}. $$ This proves all claims. \(\square\)

Connection to a Convex Distance Objective

Spatial ranks are also related to the average distance from a point to the observations. This relation explains why they can be interpreted as directional derivatives, with an important qualification when the point coincides with an observation.

Result: Define \(D_n(x)=n^{-1}\sum_{j=1}^n\|x-\mathbf{x}_j\|\). The function \(D_n\) is convex. At any \(x\) distinct from every observation, it is differentiable and \(\nabla D_n(x)=R_n(x)\). At any \(x\), including sample points, \(R_n(x)\) is a subgradient of \(D_n\).

Derivation. Each function \(x\mapsto\|x-\mathbf{x}_j\|\) is convex, so their average \(D_n\) is convex. If \(x\ne\mathbf{x}_j\), differentiation of the Euclidean norm gives $$ \nabla_x\|x-\mathbf{x}_j\|=\frac{x-\mathbf{x}_j}{\|x-\mathbf{x}_j\|}. $$ Summing these gradients and dividing by \(n\) gives \(\nabla D_n(x)=R_n(x)\) when no term is evaluated at zero.

At \(x=\mathbf{x}_j\), the norm term is not differentiable. To verify the subgradient claim, recall that \(g\) is a subgradient of a convex function \(D_n\) at \(x\) if \(D_n(y)\geq D_n(x)+g^{\mathsf T}(y-x)\) for every \(y\). For a nonzero \(z\), the inequality $$ \|w\|\geq\|z\|+\left(\frac{z}{\|z\|}\right)^{\mathsf T}(w-z) $$ follows from \( (z/\|z\|)^{\mathsf T}w\leq\|w\|\). For \(z=0\), the same subgradient inequality holds with subgradient zero because \(\|w\|\geq0\). Apply these inequalities with \(z=x-\mathbf{x}_j\), \(w=y-\mathbf{x}_j\), and add them over \(j\). The resulting inequality is \(D_n(y)\geq D_n(x)+R_n(x)^{\mathsf T}(y-x)\), as required.

The qualification matters: at a sample point the rank is a valid subgradient under the zero-sign convention, but it is not necessarily the gradient of \(D_n\), which may not be differentiable there.

Constructing Rank-Score Vectors

A spatial rank can be decomposed into its length and direction. A radial score function transforms the length, while the direction is retained. This gives a family of vector scores rather than a single mandatory choice.

Definition: Let \(K:[0,1)\to[0,\infty)\) be a specified score function. The empirical spatial rank-score vector at observation \(i\) is $$ A_{ni}= \begin{cases} K(\|R_{ni}\|)\dfrac{R_{ni}}{\|R_{ni}\|},&\|R_{ni}\|>0,\\[6pt] 0,&\|R_{ni}\|=0. \end{cases} $$ The scalar \(\|R_{ni}\|\) is the empirical rank magnitude; \(K(\|R_{ni}\|)\) is its transformed score magnitude.

The domain includes all empirical rank magnitudes because \(\|R_{ni}\|\leq(n-1)/n<1\). The zero convention avoids assigning a direction when the rank vector vanishes. A choice such as \(K(t)=t\) returns \(A_{ni}=R_{ni}\); a choice \(K(t)=t^2\) gives more relative weight to larger rank magnitudes. The score function is part of the procedure, not something determined by the data alone.

Worked Example: Applying a Radial Score Function

Use the three-point sample \((0,0),(2,0),(0,2)\) from above and choose \(K(t)=2t\). For any nonzero rank, the score vector is $$ A_{ni}=2\|R_{ni}\|\frac{R_{ni}}{\|R_{ni}\|}=2R_{ni}. $$ Thus $$ A_{n1}=\left(-\frac23,-\frac23\right), \qquad A_{n2}=\frac23\left(1+\frac1{\sqrt{2}},-\frac1{\sqrt{2}}\right), \qquad A_{n3}=\frac23\left(-\frac1{\sqrt{2}},1+\frac1{\sqrt{2}}\right). $$

For the first observation, the rank magnitude is \(\sqrt{2}/3\), so the score magnitude is \(2\sqrt{2}/3\). For each of the other observations, the rank magnitude is \(\sqrt{2+\sqrt{2}}/3\), and the score magnitude is \(2\sqrt{2+\sqrt{2}}/3\). The score changes the radial weight but leaves each rank's direction unchanged. Since this particular score is a constant multiple of the rank, the scores also sum to zero.

Worked Example: Tied Observations and a Nonlinear Score

Consider four observations: two copies of \((0,0)\) and two copies of \((1,0)\). For either observation at \((0,0)\), the comparison with the other copy contributes zero, and each of the two comparisons with \((1,0)\) contributes \((-1,0)\). Therefore its rank is $$ R_{ni}=\frac14\{(0,0)+(-1,0)+(-1,0)\}=\left(-\frac12,0\right). $$ For either observation at \((1,0)\), the two comparisons with \((0,0)\) contribute \((1,0)\) and the comparison with its duplicate contributes zero, giving rank \((1/2,0)\).

With \(K(t)=t^2\), each rank magnitude is \(1/2\), so the score magnitude is \(1/4\). The two scores at \((0,0)\) are \((-1/4,0)\), and the two at \((1,0)\) are \((1/4,0)\). The tied observations receive identical scores, and the score vectors sum to zero. Coincident observations do not require an arbitrary ordering: their pairwise difference has spatial sign zero.

Why Rank Scores Matter—and a Common Pitfall

Rank-score vectors provide a way to build multivariate procedures from directions and relative rank magnitudes rather than relying directly on raw distances. Different score functions emphasize different parts of the empirical rank distribution. These vectors are ingredients used in multivariate location procedures; the choice of score function and the calibration of a particular test depend on the inferential setting.

A common mistake is to call \(\|R_{ni}\|\) the observation's distance from the sample center, or to assume it increases whenever that distance increases. The definition does not support either claim. It averages unit directions, so its magnitude records their cancellation or alignment. For example, in the one-dimensional worked example, the endpoint gaps are unequal, yet the endpoint rank magnitudes are both \(2/3\). Another mistake is to rank the magnitudes as if they were necessarily distinct ordinal ranks. Ties can occur, and the magnitudes are real-valued vector summaries rather than a guaranteed strict ordering.

Key takeaway: An empirical spatial rank is the average of signed directions from the sample to an observation. Its direction describes net orientation, its magnitude describes directional agreement, and a radial score function transforms that magnitude while preserving direction.

Check Your Understanding

Work through these questions using the definitions and properties above.

  1. Why does the self-comparison contribute zero to an empirical spatial rank?
  2. For a sample of size \(n\), explain why an empirical spatial rank has norm at most \((n-1)/n\).
  3. What does a small spatial-rank magnitude say about the directions being averaged? Why does it not, by itself, give a distance from the sample center?
  4. How does a radial score function change a nonzero rank vector, and what happens when the rank vector is zero?
  5. Why do coincident observations receive the same empirical spatial rank when their data values are identical?
Clinical Biostats