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

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

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

where:

$p = 2(1-\Phi(|z|))$,
$s^2_{\bar{x}_k} =\frac{d_{eff} s^2_{x_k}}{n_k}$,
$n_k = n_t - n_g$,
$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}$,
$\bar{x}_k = \frac{\bar{x}_t - w_s\bar{x}_s}{1 - w_s}$,
$s_{\bar{x}_s}$ is the Standard Error of $\bar{x}_s$,
$b$ is 1 if Bessel's correction is selected for Proportions in Statistical Assumptions and 0 otherwise,
$s^2_{x_t}$ and $s^2_{x_s}$ are the estimated standard deviations for the total sample and sub-groups respectively,
$s^2_{\bar{x}_t}$ and $s^2_{\bar{x}_s}$ are the estimated standard error of the means for the total sample and sub-groups respectively,
$d_{eff}$ is Extra Deff, and
$w_s$ is the proportion of the Population represents by the sub-group.