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.
 A: 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.

*

*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$.


*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.
