###### F. ANOVA

# The One-Way ANOVA

Karl Rousseau has recently been hired as the new chair of the statistics department at UTech. In taking on his duties as the department head, he's interested in whether there's any variation in how well students do in the course, based on whether they enroll in the morning, afternoon, or evening course. A morning man himself, Prof. Rousseau has some doubt that there's much learning going on in the evening course; however, given his position as chair, he is very interested in making sure that all three sections are getting the same high-quality education. Moreover, he's too much of an empiricist to allow this idea to go untested. So he proposes that at semester's end students in all three sections take the National Assessment of Statistical Knowledge (NASK) to determine whether there are differences in student performance.

He starts by generating a null hypothesis that all three groups will have the same mean score on the test. In formula terms, if we use the symbol

**?**to represent the average score, the null hypothesis is expressed through the following notation:

Graphically, the null hypothesis can be represented in the following manner:

Notice in the graph that all three groups have the same average score (all three points are on the dashed line) and all three groups have the same SD (noted by the fact that the line around the mean point for each group is the same size). So the null hypothesis is that all three groups will have the same average score on the NASK.

The alternate hypothesis is that all means are not the same. It's important to point out that the opposite is not that all means are different (i.e., ?1 ?2 ?5 ). It is possible that some of the means could be the same, yet if they are not all identical, we would reject the null hypothesis. Rather, the alternative hypothesis is that not all means are equal.

Graphically, the alternate hypothesis might look like this:

Figure 2 highlights some important features and one of the keys to understanding ANOVA. ANOVA allows us to separate the total variability in the outcome (in this case, the variability in scores on the NASK) into two parts: variability within groups and variability between groups. As you can see from the graphs, there are differences within groups, with scores on the NASK ranging from roughly the same amount above and below the mean for each group. But there are also differences between the groups, with the evening group having somewhat higher scores than those of the afternoon group, although the means of both groups are lower than the mean of the morning group.

In table form, the scores for students look like this:

Average NASK Score | Number of Students | |

Morning | 4.12 | 313 |

Afternoon | 3.99 | 340 |

Evening | 4.37 | 297 |

4.15 | 950 |

Note: The standard deviation (SD) for each group is the same: 1.3.

With these data, we can calculate an ANOVA statistic to evaluate Prof. Rousseau's hypothesis. This is done in multiple steps, as described below.

### 1. Calculate the Variation Between Groups

The first step is to calculate the variation between groups by comparing the mean of each group (or, in this example, the mean of each of the three classes) with the mean of the overall sample (the mean score on the test for all students in this sample). This measure of between-group variance is referred to as "between sum of squares" or BSS. BSS is calculated by adding up, for all groups, the difference between the group's mean and the overall population mean, multiplied by the number of cases in the group. In formula terms:

Plugging in the values, we get the following:

This sum of squares has a number of degrees of freedom equal to the number of groups minus 1. In this case, *df _{B}* = (3-1) = 2

We divide the BSS figure by the number of degrees of freedom to get our estimate of the variation between groups, referred to as "Between Mean Squares" as:

### 2. Calculate the Variation Within Groups

To measure the variation within groups, we find the sum of the squared deviation between scores on the exam and the group average, calculating separate measures for each group, then summing the group values. This is a sum referred to as the "within sum of squares" or WSS. In formula terms, this is expressed as:

With the values from above in this formula, we have:

As in step 1, we need to adjust the WSS to transform it into an estimate of population variance, an adjustment that involves a value for the number of degrees of freedom within. To calculate this, we take a value equal to the number of cases in the total sample (N), minus the number of groups (k). In formula terms,

Then we can calculate the a value for "Within Mean Squares" as

### 3. Calculate the F test statistic

This calculation is relatively straightforward. Simply divide the Between Mean Squares, the value obtained in step 1, by the Within Mean Squares, the value calculated in step 2.

Then compare this value to a standard table with values for the F distribution to calculate the significance level for the F value (link to F-test calculator). In this case, the significance level is less than .01. This is extremely strong evidence against the null hypothesis, indicating that students' performance varies significantly across the three classes.

## Recap

To calculate an ANOVA, it is often convenient to arrange the statistics needed for calculation into a table such as the one below:

Source | Sum of Squares | Degrees of Freedom | Mean Squares |

Between | BSS | df_{B} |
Between Mean SquaresBSS/df_{B} |

Within | WSS | df_{W} |
Within Mean SquaresWSS/df_{W} |

Total | TSS = BSS + WSS |

To fill in this table with the data from the problem above, we have:

Source | Sum of Squares | Degrees of Freedom | Mean Squares |

Between | 23.36 | 2 | 11.68 |

Within | 1600.43 | 947 | 1.69 |

Total | 1623.79 | 950 |