Three training methods are randomly assigned to nine people, three per method, and each person’s time to finish a task is recorded in minutes. The method means are 4, 6 and 8 minutes, but the times inside each method also spread over several minutes. Are the means further apart than that scatter alone would make them? Running a separate t test for every pair asks three questions instead of one and raises the chance of a false alarm. One-way ANOVA answers the single question of whether all the population means are equal, and Welch ANOVA answers it without assuming equal variances.
Key terms
One-way ANOVA
Definition One-way analysis of variance (ANOVA) compares the means of groups defined by a single factor, a categorical variable such as training method. Write for observation in group , where group has observations and is the total. The classical model is
where is the population mean of group and the errors are independent and normally distributed with mean and the same variance in every group. The test compares
The groups must come from random samples of the populations being compared or from random assignment of units to treatments, and the conclusions reach only as far as that design allows. Rejecting says that at least two population means differ. It does not say which ones, and it does not say that all of them differ. With groups the test is the two-sided pooled two-sample t test, and the F statistic defined below equals the square of the pooled t statistic.
In plain words Rather than comparing the groups two at a time, ANOVA asks one question about all of them. It answers by comparing how far the group means spread apart with how much single observations scatter inside their own groups. The name refers to an analysis of variation, but the hypothesis is about means.
Example The constructed completion times are , and minutes for method A, , and for method B, and , and for method C. The group sample means are , and minutes, and the grand mean of all nine times is minutes. The null hypothesis is , against the alternative that the three population mean times are not all equal. Because the methods were randomly assigned, a rejection would support the causal conclusion that the methods do not all produce the same mean time for the people in the study.
Within-group sum of squares
Definition Let be the sample mean of group . The within-group sum of squares is
the sum of the squared deviations of all observations from their own group means. It is also called the error or residual sum of squares, and it carries the squared units of the response. For a group with observations the inner sum equals , where is the sample variance of that group, and a group with a single observation contributes .
In plain words This sum measures the variation that the grouping does not explain, the differences among units that received the same treatment. Shifting a whole group up or down leaves it unchanged, so on its own it says nothing about whether the group means differ.
Example In method A the deviations from the group mean are , and , and their squares add to . Methods B and C show the same pattern around their own means, so each also contributes , and square minutes. Equivalently, every group has sample variance , and for each group.
Between-group sum of squares
Definition Let be the grand mean of all observations, which equals . The between-group sum of squares is
the squared distance of each group mean from the grand mean, weighted by the group size. It equals exactly when all the group sample means are equal. With the total sum of squares , every data set satisfies
To see why, write and square. The cross terms add to zero, because the deviations inside each group sum to zero.
In plain words Replace every observation by its group mean and measure how much these replaced values vary around the grand mean. That is the part of the total variation the groups account for. The total splits exactly into this part and the scatter inside the groups, with nothing created or lost.
Example For the training data,
The nine deviations from the grand mean are , whose squares add to . Indeed .
Mean square
Definition A mean square is a sum of squares divided by its degrees of freedom. One-way ANOVA needs , so that some observations are left for estimating the scatter inside groups, and uses
The between-group sum has degrees of freedom because the weighted deviations sum to zero. The within-group sum has because the deviations inside each of the groups sum to zero. Together they make up the total . When the observations are independent with a common variance , normal or not,
where and . So the within-group mean square estimates whether or not holds, while the between-group mean square has expectation when all the are equal and a larger expectation otherwise. The within-group mean square is the pooled variance, and with two groups it is the pooled variance of the two-sample t test.
In plain words A sum of squares grows with the number of pieces it adds up, so each one is divided by the number of independent pieces of information it holds. The results are two estimates of the error variance on the same footing. The within-group estimate is unbiased under either hypothesis, and the between-group estimate is pushed upward, on average, when the population means differ.
Example For the training data and , so the degrees of freedom are and .
| Source | SS | df | MS |
|---|---|---|---|
| Between groups | |||
| Within groups | |||
| Total |
In a balanced design the within-group mean square is the plain average of the group sample variances, here the average of , and .
F statistic
Definition The one-way ANOVA F statistic is
Under the classical model, with independent normal errors of common variance, and when is true, the statistic has the F distribution with numerator and denominator degrees of freedom, written . Large values count against , so the p-value is the upper tail probability
computed assuming . Only the upper tail is used, although the test detects differences between the means in every direction.
In plain words The ratio compares the spread of the group means with the spread that noise alone would give them. With equal population means the ratio varies around , and a ratio far above is evidence that not all population means are equal. A significant F says that some means differ, not which ones or by how much, and a nonsignificant F does not show that the means are equal.
Example For the training data with and degrees of freedom. For two numerator degrees of freedom the tail has the closed form , so
At a level of fixed in advance the data do not reject , and the 5 percent critical value of , about , is well above . This is not evidence that the methods are equally fast. With three people per method, the data are compatible with equal population means and also with true differences larger than the ones observed.
Welch ANOVA
Definition Welch’s ANOVA tests the same while allowing the group variances to differ. It assumes independent observations, independent groups and approximately normal data within each group, and it needs and in every group. With weights , their sum and the weighted mean , let
The statistic is , where
Under it is compared with an F distribution with and degrees of freedom, where need not be a whole number. With two groups the statistic is the square of Welch’s t statistic and is the Welch-Satterthwaite degrees of freedom. The F reference is only an approximation, and the method is not free of assumptions. It still needs independence, and its p-value is less accurate for very small or strongly skewed groups.
In plain words Classical ANOVA pools all groups into one variance estimate. When the variances differ, and especially when the group sizes differ as well, the pooled estimate misstates the precision of some group means, and the classical test can reject a true much more or much less often than its stated level. It rejects too often when the smaller groups have the larger variances. Welch’s version weights each mean by its estimated precision, so a noisy mean counts for less, and it adjusts the degrees of freedom for the estimated variances.
Example Change method B to the times , and minutes and keep A and C. The means stay , and , but the sample variances become , and , so the weights are , and with . The weighted mean is by symmetry, and , so . Then and , which give
The p-value from is about . The noisy mean of B receives a quarter of the weight of each other mean, and the denominator degrees of freedom fall well below the classical .
Check yourself
- Give every method the same three times, , and minutes. Find the between-group and within-group sums of squares and the F statistic. What does the result say about the population means?
Show the answer
Every group mean equals , which is also the grand mean, so . In each group the squared deviations add to , so and . Hence and , the smallest possible value, with p-value .
The sample means show no difference at all, but no sample can show that population means are exactly equal. With three people per method, a 95 percent confidence interval for any one pairwise difference runs from about to minutes, so the data are also compatible with differences of a few minutes in either direction.
- A study randomly assigns people to three methods, five per method, and reports and . Find the mean squares, the F statistic and its p-value, and decide at level . A colleague then writes that all three methods have different mean times. Is that right?
Show the answer
The degrees of freedom are and , so , and . The closed form for two numerator degrees of freedom gives
which is about . That is below , so is rejected. Under the model’s conditions the data are evidence that the three population means are not all equal.
The colleague’s sentence does not follow. Rejecting means at least two means differ, which would also be true if one method differed and the other two were equal. Finding out which methods differ needs follow-up comparisons with control of the error rate across the comparisons, and the size of the differences needs estimates with intervals. A significant result also does not show that the differences are large enough to matter.
- For the changed data, A with , B with and C with , compute the classical F statistic and its p-value and compare them with the Welch result above. Someone suggests using the classical analysis because a test of equal variances on these data was not significant. Comment.
Show the answer
The means have not changed, so and . The within-group sum is , so and with and degrees of freedom, giving
which is about . The classical analysis pools the variances , and into , which overstates the uncertainty of the means of A and C and understates that of B. Welch’s analysis uses each group’s own variance and gives with p about . Neither rejects at .
With three observations per group, a test of equal variances has little power, so failing to reject does not show that the variances are equal. The choice of analysis should come from the design and what is known about the variability, and Welch’s version is a common choice whenever the variances may differ. It still requires independent observations and roughly normal data within groups.