Tutorials › Multivariate Statistics (Graduate) › One-Sample Tests from Depth Contours

Ranks and Nonparametric Methods · Tutorial 768 of 975

One-Sample Tests from Depth Contours

Use depth at a proposed location as a test statistic, then calibrate it with sign flips under central symmetry and interpret its affine invariance.

Advanced 11 min read

What You'll Learn

  • Define empirical halfspace depth and its central contour regions.
  • Form a lower-tail test of a proposed symmetry center using depth at that point.
  • Derive finite-sample sign-flip calibration under independent central symmetry.
  • Calculate discrete depth-test p-values, including tied reference values.
  • Distinguish affine invariance from distribution-free calibration.
  • Identify when sign-flip validity does not apply to a proposed location null.

Testing a Proposed Center with Depth

A multivariate location test asks whether a proposed point is consistent with the center of a distribution. A depth function makes this question geometric: points deep inside a distribution’s contours are central, while points in shallow regions are peripheral. For a one-sample test, the depth of the proposed center can serve as a statistic. If that depth is unusually low relative to its null distribution, the data provide evidence against the proposed center.

Depth does not by itself supply a calibration rule. The same depth value can be common under one distribution and rare under another. A useful finite-sample calibration is available when the observations are independent and centrally symmetric about the null point: flipping any subset of the centered observations leaves their joint distribution unchanged. This invariance provides a reference distribution for the observed depth.

Definition: For a random vector \(X\) in \(\mathbb{R}^d\) with distribution \(F\), its halfspace depth at \(x\in\mathbb{R}^d\) is $$ HD(x;F)=\inf_{u\in\mathbb{S}^{d-1}}P(u'X\geq u'x), $$ where \(\mathbb{S}^{d-1}\) is the unit sphere. For observations \(Y_1,\ldots,Y_n\), the empirical halfspace depth is $$ HD_n(x;Y)=\inf_{u\in\mathbb{S}^{d-1}}\frac{1}{n}\sum_{i=1}^n\mathbf{1}\{u'Y_i\geq u'x\}. $$ The depth region, or contour region, at level \(\gamma\) is \(C_n(\gamma)=\{x:HD_n(x;Y)\geq\gamma\}\).

The use of a weak inequality in this definition means observations on a bounding hyperplane are counted. Other conventions are possible, but a test’s statistic and its reference distribution must use the same convention. In this tutorial the statistic is the depth of the hypothesized center, and small values are evidence against the null.

The Sign-Flip Depth Test

Let \(X_1,\ldots,X_n\) be independent random vectors and test the null hypothesis that each is centrally symmetric about a specified point \(\theta_0\). Central symmetry means that \(X_i-\theta_0\) and \(-(X_i-\theta_0)\) have the same distribution. The observations need not be identically distributed. If the distributions have finite means, \(\theta_0\) is also their common mean; without that moment condition, the null concerns a symmetry center, not necessarily a mean.

Set \(Y_i=X_i-\theta_0\). For each sign vector \(s=(s_1,\ldots,s_n)\in\{-1,1\}^n\), form the sign-flipped sample \(sY=(s_1Y_1,\ldots,s_nY_n)\). Its depth statistic is \(T(sY)=HD_n(0;sY)\). The lower-tail sign-flip p-value is

$$ p_{\mathrm{sf}}=\frac{1}{2^n}\sum_{s\in\{-1,1\}^n}\mathbf{1}\{T(sY)\leq T(Y)\}. $$

The observed sign vector is included in the sum. Thus the comparison uses “less than or equal to,” not just “less than”: ties contribute to the p-value. Rejecting when \(p_{\mathrm{sf}}\leq\alpha\) gives a test of level at most \(\alpha\). With a discrete reference distribution, its size will generally be below \(\alpha\) unless randomized tie-breaking is used.

Theorem: If \(Y_1,\ldots,Y_n\) are independent and each has a distribution symmetric about zero, then for any fixed statistic \(T\), the sign-flip p-value defined by comparing \(T(sY)\) with \(T(Y)\) using “less than or equal to” satisfies \(P(p_{\mathrm{sf}}\leq\alpha)\leq\alpha\) for every \(0\leq\alpha\leq1\). This applies in particular to empirical halfspace depth at zero.

Proof. Let \(G=\{-1,1\}^n\), a finite group acting on samples by coordinatewise sign changes. Independence and central symmetry imply that \(Y\) and \(gY\) have the same distribution for every \(g\in G\). For any fixed sample, list the \(M=2^n\) statistic values \(T(gY)\), one for each group element, retaining repetitions. Order this multiset from smallest to largest. If a value occupies positions \(a\) through \(b\), then the p-value assigned to every occurrence of that value is \(b/M\), because the comparison counts all values less than or equal to it.

Now choose a group element uniformly at random. Among the \(M\) listed occurrences, the number whose p-value is at most \(\alpha\) is at most \(\alpha M\): any included occurrence has rank at most \(\alpha M\), and ties can only move the p-value to the end of a tied block, not increase this count. Consequently, the fraction of group elements producing a p-value at most \(\alpha\) is at most \(\alpha\). Since the distribution of \(Y\) is invariant under the group, averaging this bound over \(Y\) gives \(P(p_{\mathrm{sf}}\leq\alpha)\leq\alpha\). Repeated statistic values, including those caused by zero observations, are already handled by the weak inequality and the tied-block argument. \(\square\)

Worked Examples

Worked Example: A Univariate Depth Test

Suppose the null center is \(0\) and the observed residuals are \(Y=(1,2,4)\). Compute the empirical halfspace depth at zero and its exact sign-flip p-value.

In one dimension, the two possible directions are \(u=1\) and \(u=-1\). With no zero observations, if \(k\) of the three residuals are positive, then $$ HD_n(0;Y)=\frac{\min(k,3-k)}{3}. $$ The observed sample has \(k=3\), so its depth is \(0\).

Across all eight sign patterns, one pattern has \(k=0\), three have \(k=1\), three have \(k=2\), and one has \(k=3\). Their depths are respectively \(0,\frac{1}{3},\frac{1}{3},0\). Exactly two of the eight depths are less than or equal to the observed depth \(0\), so \(p_{\mathrm{sf}}=2/8=0.25\). At level \(0.05\), the test does not reject. The p-value is not small simply because all observed residuals have the same sign; with only three observations, two of the eight equally weighted sign patterns are at least as extreme in this depth sense.

Worked Example: Counting Tied Contour Values Correctly

In \(\mathbb{R}^2\), take three residual vectors \(a=(1,0)\), \(b=(0,1)\), and \(c=(-1,-1)\). Use the contour statistic \(T(sY)=\mathbf{1}\{HD_n(0;sY)>0\}\), which records whether zero has positive empirical halfspace depth. Suppose the observed sign pattern is \((+,-,+)\), giving \((a,-b,c)\). Find the lower-tail p-value.

For three points in the plane, zero has positive halfspace depth when it lies in their convex hull. With signs \((+,+,+)\), the vectors sum to zero, so zero lies inside their triangle. The global reversal \((-,-,-)\) also has zero inside its triangle. In each of the other six patterns it is outside: for \((+,+,-)\), all three vectors have nonnegative coordinates and are nonzero; for \((+,-,+)\), a convex combination with zero first coordinate must give equal weights to \(a\) and \(c\), whose second coordinates are both nonpositive after including \(-b\), so they cannot sum to zero with positive weights. For \((+,-,-)\), writing the weights on \(a,-b,-c\) as \(w_a,w_b,w_c\geq0\), a zero combination would require \(w_a+w_c=0\) and \(-w_b+w_c=0\). The first equation forces \(w_a=w_c=0\), and the second then forces \(w_b=0\), so no weights summing to one can give zero. The three remaining mixed patterns are the global reversals of these cases and also exclude zero from their convex hulls.

Thus \(T=1\) for two sign patterns and \(T=0\) for the other six. The observed pattern \((+,-,+)\) has \(T=0\). The lower-tail comparison counts values less than or equal to zero, so it counts the six zeros, not the two ones. Therefore \(p_{\mathrm{sf}}=6/8=0.75\). This calculation illustrates why ties must be counted using the specified inequality.

Worked Example: Checking Affine Invariance Numerically

Take the one-dimensional residuals \(Y=(1,2,3,-6)\). The observed sample has three positive entries and one negative entry. Apply the affine transformation \(x\mapsto 4x+7\) to the original observations and transform the null center \(0\) to \(7\). Verify that the depth test is unchanged.

Before transformation, the observed depth at zero is \(\min(3,1)/4=1/4\). For four residuals, depth is zero when all signs agree and \(1/4\) when there is one or three positive signs. The sign patterns with depth at most \(1/4\) are those with \(k=0,1,3,4\) positive signs. Their number is $$ \binom{4}{0}+\binom{4}{1}+\binom{4}{3}+\binom{4}{4}=1+4+4+1=10. $$ Hence \(p_{\mathrm{sf}}=10/16=0.625\).

After transformation, the observations are \(11,15,19,-17\), and the transformed null center is \(7\). Subtracting \(7\) gives residuals \((4,8,12,-24)=4Y\). Multiplication by a positive constant preserves every sign pattern and every univariate depth at zero. The observed depth remains \(1/4\), the same ten sign patterns are counted, and the p-value remains \(10/16=0.625\).

Why Invariance Helps—and What It Does Not Do

Halfspace depth is affine invariant: under an invertible affine map \(x\mapsto Ax+b\), the depth of \(x\) equals the depth of \(Ax+b\) in the transformed distribution. An invertible affine map sends halfspaces bijectively to halfspaces, so the probabilities in the depth definition are merely re-indexed. Applying the same map to the observations and the proposed center therefore preserves the depth statistic for each sign pattern. The sign-flip p-value is unchanged as well.

This invariance allows a location test to be expressed in transformed coordinates without changing its conclusion. It is distinct from the reason the test is calibrated: finite-sample validity comes from the sign-flip invariance of the joint distribution under the symmetry null. Affine invariance of a statistic alone does not give a valid null distribution, and sign-flip calibration is not distribution-free over arbitrary distributions.

A contour test can also be described as checking whether the proposed center lies in a specified empirical depth region. For example, \(0\notin C_n(\gamma)\) is equivalent to \(HD_n(0;Y)<\gamma\). But choosing \(\gamma\) alone does not automatically give a test at a desired significance level. To obtain a calibrated test, treat the depth—or another prespecified contour statistic—as a statistic and compare its observed value with its null reference distribution. Under the symmetry conditions above, sign flips provide such a reference distribution. Under a different model, calibration must instead follow from that model’s assumptions and null distribution.

Common Mistakes

  • Counting only strictly smaller reference values. The p-value here counts \(T(sY)\leq T(Y)\), so all tied values count. Omitting ties can make the test anti-conservative.
  • Assuming a low depth has a universal cutoff. The depth’s null distribution depends on the sample size, dimension, statistic, and null assumptions. Calibrate it rather than applying an arbitrary universal threshold.
  • Calling the null a mean hypothesis without conditions. Central symmetry identifies a symmetry center. It identifies a mean only when the relevant expectation exists.
  • Confusing affine invariance with distribution-free validity. Invariance of the depth statistic under coordinate changes does not justify sign flips when the observations are not centrally symmetric about the null point.
Key takeaway: A one-sample depth test measures how central the proposed location is in the observed data. Under independent central symmetry, the distribution of that measure can be calibrated by enumerating sign flips; the resulting test is finite-sample valid, with ties handled conservatively. Affine invariance preserves the test under nonsingular changes of coordinates, but does not replace the symmetry assumption.

Check Your Understanding

Use the definitions and calibration rule above to answer the following.

  1. Why does the sign-flip test use a lower-tail comparison for depth at the proposed center?
  2. For the three-point planar example, if the observed statistic is zero and two of eight reference values are one, how many values enter the p-value numerator?
  3. What assumption makes the joint distribution invariant under independent sign changes?
  4. Does affine invariance by itself establish that a sign-flip p-value is valid? Explain.
  5. When can a central-symmetry center also be interpreted as a population mean?
Clinical Biostats