# Complex Samples Dependent T-Test - Comparing a Sub-Group Mean to Total

Where $\displaystyle{ \bar{x}_t }$ is the mean in the total sample and $\displaystyle{ \bar{x}_s }$ is the mean in the sub-group, $\displaystyle{ n_t }$ and $\displaystyle{ n_s }$ are their respective effective sample sizes, and $\displaystyle{ w_s }$ is the proportion of the total population in sub-group $\displaystyle{ s }$:

$\displaystyle{ t=\frac{\bar{x}_t-\bar{x}_s}{(1 - w_s)\sqrt{s^2_{\bar{x}_s} + s^2_{\bar{x}_k}}} }$,

where:

$\displaystyle{ p = 2\Pr(t_v \ge |t|) }$,
$\displaystyle{ s^2_{\bar{x}_k} =\frac{d_{eff} s^2_{x_k}}{n_k} }$,
$\displaystyle{ n_k = n_t - n_g }$,
$\displaystyle{ s^2_{x_k} = \frac{s^2_{x_t} (n_t - b) - s^2_{x_s} (n_s - b) - (\bar{x}_t - \bar{x}_s)^2 n_s- (\bar{x}_t - \bar{x}_k)^2 n_k}{n_k - b} }$,
$\displaystyle{ \bar{x}_k = \frac{\bar{x}_t - w_s\bar{x}_s}{1 - w_s} }$,
$\displaystyle{ s_{\bar{x}_s} }$ is the Standard Error of $\displaystyle{ \bar{x}_s }$,
$\displaystyle{ v = \frac{(\frac{s^2_{\bar{x}_s}}{n_s} +\frac{s^2_{\bar{x}_s}}{n_k})^2}{\frac{(\frac{s^2_{\bar{x}_s}}{n_s})^2}{n_s-b}+\frac{(\frac{s^2_{\bar{x}_s}}{n_k})^2}{n_k-b} } }$, or, if Weights and significance is set to Un-weighted sample size in tests (see Weights, Effective Sample Size and Design Effects), $\displaystyle{ v = n_t - 2b }$
$\displaystyle{ b }$ is 1 if Bessel's correction is selected for Proportions in Statistical Assumptions and 0 otherwise,
$\displaystyle{ s^2_{x_t} }$ and $\displaystyle{ s^2_{x_s} }$ are the estimated standard deviations for the total sample and sub-groups respectively,
$\displaystyle{ s^2_{\bar{x}_t} }$ and $\displaystyle{ s^2_{\bar{x}_s} }$ are the estimated standard error of the means for the total sample and sub-groups respectively,
$\displaystyle{ d_{eff} }$ is Extra Deff, and
$\displaystyle{ w_s }$ is the proportion of the Population represents by the sub-group.