Comparing a subgroup mean with its containing sample mean (source code)

= Comparing a subgroup mean with its containing sample mean
{title2=$\overline X_A-\overline X=(1-w)(\overline X_A-\overline X_B)$}

Partition a sample into two disjoint groups $A,B$ with fixed positive sizes $n_A,n_B$, and let $w=n_A/(n_A+n_B)$. The overall <sample mean> is the <weighted mean>
$$
\overline X=w\overline X_A+(1-w)\overline X_B.
$$
Subtracting gives the displayed identity. The subgroup and overall <sample means> share observations, so they are not <independent>. If the two disjoint groups are sampled <independently>, then
$$
\operatorname{Cov}(\overline X_A,\overline X)=w\operatorname{Var}(\overline X_A),\qquad
\operatorname{Var}(\overline X_A-\overline X)=(1-w)^2\left\{\operatorname{Var}(\overline X_A)+\operatorname{Var}(\overline X_B)\right\}.
$$
Thus treating the subgroup and the combined sample as two <independent> samples uses the wrong <standard error>. Equality of the subgroup and overall population means is equivalent to equality of subgroup and complement means when both groups have positive weight, but the <sampling distribution> must respect the shared observations.