# A question on a non-parametric estimating equation

This is a question that arose from studying Hogg and Craig "Introduction to Mathematical Statistics",7th edition, pg 568.

It is assumed that we have taken a random sample of $X_1,\ldots,X_{n1}$ and a random sample of $Y_1,\ldots, Y_{n_2}$, $n$ denotes the combined sample size, i.e. $n=n_1+n_2$ and sgn(.) is $1$ if the quantity in the brackers is positive,$0$ if it is zero and $-1$ if it is negative. We also rank the variables from low to high.

Could you please help me understand how the authors reach the conclusion that the difference in medians estimator solves that equation? There is no explanation from their part and the word "easily" seems out of place :)

Thank you.

• When there are no ties in the dataset, how many values $X_i$ exceed the median (and therefore the residuals $X_i-\text{med}\{X_j\}$ have signs of $+1$), how many values equal it (whose residuals thus have signs of $0$), and how many values are less than it (whose residuals thus have signs of $-1$)? What does that tell you about the sum of the signs of the residuals? Conversely, if a value does not have this defining property, what can you say about the sum of signs of the residuals w.r.t this value? Finally, what assumptions do H & C make to eliminate the difficulties with tied values? – whuber May 19 '14 at 19:32
• @whuber Thank you for your clarifications, I will think about the points you made. The assumption that eliminates tied values is a continuous distribution both for $X$ and for $Y$ – JohnK May 19 '14 at 19:36
• $(n+1)/2$ is the median of the $n=n_1+n_2$ ranks. Note, too, that the ranking procedure preserves the signs of the residuals: when a value exceeds the median, the rank of that value exceeds the median rank, etc. – whuber May 19 '14 at 21:26
• I haven't the time to write it up, but perhaps this will help: one you have appreciated the connection between the sum of signs and the median, the entire idea can be summed up as follows. (10.5.36) asks, how much would you have to shift the $Y$s so that their median coincides with the median of $X$? One way to figure it out is to shift both the $X$s and the $Y$s to make their medians coincide at $0$, and then reverse your steps. The $Y$s have to shift by $\text{med}\{Y_i\}$ and then we have to shift that back by $-\text{med}\{X_i\},$ QED. – whuber May 19 '14 at 21:48
• @whuber Since $\frac{n+1}{2}$ is the median rank of the combined sample, doesn't $10.5.6$ ask us how much $Y$ has to shift so that the median of $Y$ coincides with the median of $n=n_1+n_2$ values? Why is it the median of $X$ instead? – JohnK May 20 '14 at 7:24

There is an issue here, nicely captured by the latest comment to the question:

Doesn't [Equation] 10.5.6 ask us how much $Y$ has to shift so that the median of $Y$ coincides with the median of $n=n_1+n_2$ values? Why is it the median of $X$ instead?

When the meaning of the equation is parsed--translated from math-ese into meaningful English--the answer becomes clear.

### Translating Math to English

Let's begin by clarifying the context. Two datasets $X=(x_i,\,i=1,\ldots,n_1)$ and $Y=(y_i,\,i=1,\ldots,n_2)$ are each assumed to arise from sampling two continuous distributions. (The continuity assumption is merely a convenience to allow us to assume all the values are distinct.) The analysis is concerned with shifting the values: all the $y_i$ will be reduced by a constant $\Delta$ (to be determined later). These data--that is, the original $X$ and the shifted $Y_\Delta = (y_1-\Delta, y_2-\Delta, \ldots, y_{n_2}-\Delta)$--are combined into a single dataset $X\cup Y_\Delta = Z_\Delta=(z_i,\,i=1,\ldots,n=n_1+n_2)$ and sorted so that $z_i \le z_{i+1}$ for all $1\le i\lt n$. The position in the sort order is the rank of the value, written here as a function $R$:

$$R(z_j)=j.$$

(As $\Delta$ varies, there will occasionally be two-way ties between some elements of $X$ and $Y_\Delta$. The rank function $R$ can be--and usually is--extended by assigning to any tied group the average of the ranks each element of the group would receive if the tie were arbitrarily resolved.)

In this fashion each of the elements of $X$ and $Y_\Delta$ receives a rank between $1$ and $n$. The middle rank of $(n+1)/2$ splits the ranks into two halves: the upper half $H^{+}$ consists of all ranks strictly greater than $(n+1)/2$ and the lower half $H^{-}$ consists of all ranks strictly less than $(n+1)/2$. The appearance of the signum function, written $\text{sgn}$, in the equation simply assigns the value $1$ to elements in the upper half and $-1$ to elements in the lower half. Another way to write the sum in Equation 10.5.6 is to collect all the terms that are assigned $+1$ into one group--these are the elements of $Y$ in the upper half--and all the terms that are assigned $-1$ into another group. Evidently the sum reduces to a difference of counts:

$$0 = \sum_{i=1}^{n_2} \text{sgn}\left(R(y_i-\Delta) - \frac{n+1}{2}\right) = |Y_\Delta \cap H^{+}| - |Y_\Delta \cap H^{-}|$$

(where $|\cdot|$ denotes the number of elements in a set).

In other words, the equation asks that $Y_\Delta$ be balanced (as a subset of $Z_\Delta$) in the sense that the number of elements contained in the upper and lower halves of $Z_\Delta$ be equal:

$$|Y_\Delta \cap H^{+}| = |Y_\Delta \cap H^{-}|.$$

(More generally, let's say that any finite set of numbers $W$ is balanced about some value $m$ when there are equally many values in $W$ that exceed $m$ as there are less than $m$. Any such $m$ is called a median of $W$.)

The task before us, then, is

By how much ($\Delta$) should the data $Y$ be shifted in order to balance $Y_\Delta$ within $Z_\Delta = X \cup Y_\Delta$?

### Solving the Equation

The claim is that $Y$ must be shifted until a median of $Y_\Delta$ (equal to a median of $Y$, $m_Y$, minus $\Delta$) is a median for $X$. This is really two claims, which I will address in order of difficulty.

1. When $\Delta = m_Y - m_X,$ $Y_\Delta$ is balanced.

The number of elements of $Z_{m_Y-m_X}$ exceeding $m_X$ is the number of elements of $X$ exceeding $m_X$ plus the number of elements of $Y$ exceeding $m_Y$. These each equal the numbers of elements less than $m_X$ and $m_Y,$ respectively, whence $m_X$ is a median of $Z_\Delta$ and $Y_\Delta$ must be balanced in $Z_\Delta$.

2. When $Y_\Delta$ is balanced, $\Delta$ can be expressed as the difference between a median of $X$ and a median of $Y$.

The assumption is that the number of elements of $Y_\Delta$ in the upper half of $Z_\Delta$ equals the number in the lower half of $Z_\Delta$. (Equivalently, the median of $Z_\Delta$ is a median of $Y_\Delta$.) Consequently, the number of elements in the upper half of $Z_\Delta$ that are not in $Y_\Delta$ equals the number in the lower half of $Z_\Delta$ that are not in $Y_\Delta$. Since all such elements are in $X$, $X$ is also balanced as a subset of $Z_\Delta$. That means nothing other than that the median of $Z$ is a median of $X$.

We conclude that a median of $Z$ coincides both with a median of $X$, $m_X$, and a median of $Y_\Delta$, $m_Y - \Delta$. The desired conclusion follows immediately.

• Thank you very much for taking the time to provide a complete answer. I'll get right on it. – JohnK May 21 '14 at 15:03
• While I understand very well the second claim, I am having trouble comprehending why the number of elements of $Y$ which exceed $m_X$ is equal to the number of elements of $Y$ that exceed $m_Y$ Using an indicator function $\sum_{j=1} ^{n_2} I(Y_j-m_X+m_Y>m_X)=\sum_{j=1} ^{n_2} I(Y_j>2m_X-m_Y)$, yes? – JohnK May 21 '14 at 16:02
• I don't think I wrote that--although I did reverse the order and wrote $m_X-m_Y$ instead of $m_Y-m_X$, which I have since fixed. The first claim deals with $Z_{m_Y-m_X},$ which is formed out of $X$ and $Y_{m_Y-m_X}.$ Thus we are comparing values of the form $y_i - (m_Y-m_X) = (y_i-m_Y) + m_X$ to $m_X$, which is tantamount to comparing the $y_i$ to $m_Y$, not $m_X$. – whuber May 21 '14 at 17:23
• Yes indeed. It was the sign that confused me, thank you. – JohnK May 21 '14 at 17:46