# Show change of expression of sample variance and explain the distribution

Show that $$\sum\left(Y_{i}-\mu\right)^{2} / \sigma^{2}=(n-1) S^{2} / \sigma^{2}+\left[(\bar{Y}-\mu)^{2} n / \sigma^{2}\right]$$

can be changed into a form $$\frac{1}{\sigma^{2}} \widehat{S}_{1}=\frac{1}{\sigma^{2}} \sum_{j=1}^{2} \sum_{k=1}^{20}\left(Y_{j k}-\mu_{j}\right)^{2}-\frac{20}{\sigma^{2}} \sum_{k=1}^{20}\left(\bar{Y}_{j}-\mu_{j}\right)^{2}$$ and deduce that $$\frac{1}{\sigma^{2}} \widehat{S}_{1} \sim \chi^{2}(38)$$ Similarly show that $$\frac{1}{\sigma^{2}} \widehat{S}_{0}=\frac{1}{\sigma^{2}} \sum_{j=1}^{2} \sum_{k=1}^{20}\left(Y_{j k}-\mu\right)^{2}-\frac{40}{\sigma^{2}} \sum_{j=1}^{2}(\bar{Y}-\mu)^{2}$$ and if $$\mathrm{H}_{0}$$ is true then $$\frac{1}{\sigma^{2}} \widehat{S}_{0} \sim \chi^{2}(39)$$

Provided that $$\begin{array}{l} \hat{S}_{0}=\sum \sum\left(Y_{j k}-\bar{Y}\right)^{2}, \text { where } \bar{Y}=\sum_{j=1}^{2} \sum_{k=1}^{K} Y_{j k} / 40 \\ \hat{S}_{1}=\sum \sum\left(Y_{j k}-\bar{Y}_{j}\right)^{2}, \text { where } \bar{Y}_{j}=\sum_{k=1}^{K} Y_{j k} / 20 \end{array}$$ for $$j=1,2$$

Intuitively I can explain why $$\hat{S_0}/\sigma^2$$ would look the way it is as we can simply consider $$\sum\left(Y_{i}-\mu\right)^{2} / \sigma^{2}=(n-1) S^{2} / \sigma^{2}+\left[(\bar{Y}-\mu)^{2} n / \sigma^{2}\right]$$ is the expression for one gender, group, so for this to be true for both gender group, we have to sum across two genders. However, I am unable to show why $$\hat{S}_1$$ looks the way it is. Also, Suppose the expression is true, why Chi-square distribution is with a degree of freedom 38 and 39?

• There are two hypotheses: $H_0:\mu_1=\mu_2=\mu$ and $H_1:\mu_1\ne\mu_2$. We have $\hat{S}_0$ when $H_0$ holds (only one overall mean, 39 degrees of freedom), $\hat{S}_1$ when $H_1$ holds (two distinct group means, 38 d.o.f.) Commented Sep 14, 2020 at 10:44
• @Sergio Yes, but I am struggling to get this conclusion from the formula which is part of my question
– JoZ
Commented Sep 15, 2020 at 14:23

As to $$\hat{S}_1$$, I think that there is a small typo in book's equations.
Let's consider the first group, $$j=1$$. We have (see previous question/answer): $$\sum_{k=1}^{20} (y_{1k}-\bar{y}_1)^2=\sum_{k=1}^{20}(y_{1k}-\mu_1)^2-20(\bar{y}_1-\mu_j)^2$$ To get $$\hat{S}_1=\sum_{j=1}^2\sum_{k=1}^{20}(y_{jk}-\bar{y}_j)^2$$, we have to sum two equations putting $$j=1,2$$: $$\sum_{j=1}^2\sum_{k=1}^{20} (y_{jk}-\bar{y}_j)^2=\sum_{j=1}^2\sum_{k=1}^{20}(y_{jk}-\mu_j)^2-\sum_{j=1}^2 20(\bar{y}_j-\mu_j)^2$$ Not $$\sum_{k=1}^2$$ in the last term. If we divide by $$\sigma^2$$, then on the right side we have:
• the sum of $$40$$ squared standard normal variables, independent because $$y$$ is i.i.d., $$\sim\chi^2_{40}$$;
• minus the sum of two squared standard normal variables, independent because $$y$$ is i.i.d. and $$\mu_1\ne\mu_2$$ by $$H_1$$, $$\sim\chi^2_2$$;
so the left side is $$\sim\chi^2_{38}$$.