I know this is a basic question about ANOVA, but I don't understand why it's important to have homogeneity of variance across different groups within a factor, when you are 'analyzing the variance' to find statistical diffrerenes in the means of those groups. Why would the structure of the residual variance matter? What does the test achieve by assuming that the variance is approximately equal across different groups within a factor?
1 Answer
To observe an exceptional (high) F-score can be due to the means of the groups being different, but just as well due to the deviations of the groups being different. So we need to be sure that the assumption of equal group variances is correct or strong enough.
When the group variances are equal
then the F-score would be distributed like
$$F_{k_1,k_2} = \frac{X_{1}/k_1}{X_{2}/k_2} \qquad \text{where } X_{i} \sim \chi^2(k_i) $$
where
- the numerator relates to the mean squared residuals the of the group means in relation to the overall mean
- and the denominator relates to the mean squared residuals of the measurements in relation to the respective group means.
When the group variances are not equal
we are gonna make this comparison for two groups only
When we compare the means of two groups then more generally, if we assume variance and groups size not necessarily equal, then the F score is slightly different distributed (more complicated) (where $n=n_1+n_2$ is the total number of observations in group 1 and 2):
$$ F^\star = \frac{n-2}{1} \frac{\left(\frac{n_2}{n_1+n_2}\sigma_1^2 + \frac{n_1}{n_1+n_2} \sigma_2^2 \right) X_3}{\sigma_1^2 X_{1}+ \sigma_2^2X_2} \\ \qquad\qquad\qquad\qquad\qquad \text{where } X_{1} \sim \chi^2(n_1-1), X_{2} \sim \chi^2(n_2-1) , X_{3} \sim \chi^2(1) $$
derivation given below
which if $\sigma_1 = \sigma_2 = \sigma$ would become
$$ F^\star = \frac{n-2}{1} \frac{\sigma^2 X_3}{\sigma^2 X_{1}+ \sigma^2X_2} =\frac{n-2}{1} \frac{X_3}{X_1+X_2} \qquad \text{where } X_{i} \sim \chi^2(k_i) $$
which is like the typical F distribution. But this is not true when $\sigma_1 \neq \sigma_2$, so false conslusions are being made when the typical F distribution is used to calculate p-values when this F distribution is not the true distribution for the F-score.
Intuitive
An extreme case might be more intuitive. Say $\sigma_2 =0$. That is, all the values in the other groups are equal to zero. Then,
$$ F^\star = \frac{n-2}{1} \frac{n_2}{n} \frac{X_3}{X_{1}} \approx \frac{n_2}{1} \frac{X_3}{X_{1}} $$
Then both terms in the denominator and numerator will be related to $\sigma_1$, but the term in the denominator will be a sum of squared residuals with much lower degrees of freedom (and overall thew term will be less) and the term in the nominator will be related to the variance of the mean of the first group $\mu_1 \sim N(0,\frac{\sigma_1^2}{n_1})$ but scaled by a factor $\frac{n-n_1}{n}$.
So there are two effects:
- A lower (relative) SSR for in between group residuals, because only one group is the one that mostly varies and has an effect on variance in relation the overall mean.
- A lower (relative) SSR of the within group residuals, because it is mostly only one group (with the highest variance) that contributes.
Both numerator and denominator tend to be smaller and these effects, depending on the group sizes, can make the F-score either larger or smaller.
Example of the distributions with simulations
The figure below demonstrates how the F-scores will not be similarly distributed when $\sigma_1 \neq \sigma_2$ by using plots of a few simulated examples (1000 simulations of data assuming $H_0$, equal group means, is true, but allowing different variances and group sizes)
In the image on the left we have chose a very large difference $\sigma_1 >> \sigma_2$ with equal group sizes. It shows how the the distribution of the F-score tends to go towards an F-distribution with a lower number of degrees of freedom for the denominator term.
In the image on the right we show how the effect will be when the group sizes are different (in addition to different variances). The effect will be roughly a scaling of the F-score, and the result can be either that the F-score is higher or lower than the naive F-distribution.
Remark
The above shows intuitively the differences in distributions of F-scores when there are two groups. In that case the distribution can still be described rather easily.
For many groups this becomes more difficult (although not impossible, the denominator term just extends with more terms and the numerator term will be some sum with additional terms where the factors are determined by a rotation of the matrix for the multivariate normal distribution of the means).
But anyway, the bottom line is that the F-distribution is only correct when the assumption holds that the $\sigma$ are equal, and possible deviations are less bad when the group sizes are relatively equal. The principle how the distribution for the F-score may deviate holds the same when there are more than two groups.
Derivation for numerator term The between groups sum of squared residuals (SSR) with means $\bar{Z_1}$ and $\bar{Z_2}$ are related to the difference $\bar{Z_1}-\bar{Z_2}$, which has a normal distribution $$\bar{Z_1}-\bar{Z_2} \sim N(0,\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2})$$ The residuals in group 1 will be $r_1=\frac{n_2}{n_1+n_2}\left( \bar{Z_1} - \bar{Z_2} \right)$ and the residuals in group 2 will be $r_2=\frac{-n_1}{n_1+n_2}\left( \bar{Z_1} - \bar{Z_2} \right)$. The total SSR will then be the sum of those and results in: $$SSR_{between} = n_1 r_1^2 + n_2 r_2^2 = \frac{n_1+n_2}{n_1 n_2} \left( \bar{Z_1} - \bar{Z_2} \right)^2 $$ which has variance:$$\text{Var}(\sqrt{SSR_{between}}) = \frac{n_1 + n_2}{n_1 n_2} \left( \frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2} \right) = \frac{n_2}{n_1+n_2} \sigma_1^2 + \frac{n_1}{n_1+n_2} \sigma_2^2$$ Derivation for denominator term If you have $n_k$ variables distributed as $N(0, \sigma_k^2)$ and take the sum of their squares then you will get a product of a chi-squared distributed variable X (which is related to standard normal distributed variables) like $\sigma_k^2 X_k$, when you take the sum of squares of their difference with the group mean, then you get a product of a chi-squared distributed variable X with one less degree of freedom.