One-way ANOVA
Definitions & Key takeaways
One-way analysis of variance, or simply, ANOVA, is a type of parametric statistical test used to determine if there's a significant difference between the means or averages of three or more groups.
To perform a one-way ANOVA, you need to have at least two groups of data that you want to compare. You can then calculate the mean, variance, and standard deviation of each group. The one-way ANOVA test uses these values to determine whether there is a significant difference between the means of the groups.
This test is often used in scientific research to compare the means of different groups, such as comparing the effectiveness of different medications or treatments.
Analysis of variance, or simply, ANOVA, is a type of parametric statistical test used to determine if there’s a significant difference between the means or averages of three or more groups.
And significance is normally defined by a p-value of less than 0.05 or 5%. Now when doing any parametric test, there are three key assumptions that we have to make about the population.
First, the sample population must have been recruited randomly. Choosing names randomly ensures that the people included in the study will have similar characteristics to the target population.
This is important because that ensures that the results of the t-test can be applied to the target population - meaning it has good external validity!
The second assumption is that each individual in the sample was recruited independently from other individuals in the sample.
In other words, no individuals influenced whether or not any other individual was included in the study. For example, if two friends decided to get their blood pressures measured on the same day, and they were both included in the study, these two individuals would not be independent of each other and the second assumption would not be met.
Like random sampling, independent recruitment of individuals is important because it ensures that the sample population approximates the target population.
The third assumption is that the sample size is large enough to approximate the target population, which usually means having more than 20 people.
If it’s impossible to get a large sample size, then the sample population must follow a normal bell-shaped distribution for the characteristic being studied because that’s what we would expect to see in the target population.
Okay, now let’s say there are three medications available for lowering systolic blood pressure, and you want to figure out if any of the medications work differently than the others.
Let’s say that you find 10 people who take Medication A for 6 weeks, and that afterwards the mean systolic blood pressure for the group is 130 mmHg.
Then, you find another 10 people who have been taking Medication B - and afterwards their mean systolic blood pressure is 138 mmHg, and finally you find 10 people who have been taking Medication C - and afterwards their systolic blood pressure is 132 mmHg.
Now, the next step is to figure out if 130, 138, and 132 are significantly different from one another, and you do that by performing an ANOVA test.
Specifically, we would use a one-way ANOVA, because we’re looking at one independent variable - which is medication type - that has multiple levels or groups, which are Medication A, B, and C.
This is different than a multi-way ANOVA, which looks at two or more independent variables that each have multiple groups.
For example, a two-way ANOVA could compare the systolic blood pressure of older and younger people who are using different medications.
In that case, the first independent variable is the medication type and the second independent variable is age category.
A third type of ANOVA test is the repeated measures ANOVA, which looks at the same group of people at multiple time periods.
For example, you could look at only people taking Medication A at 1 month, 3 months, and 6 months to see if their systolic blood pressure lowers over time.
In this case, the independent variable is time, and it has three groups - the three different months - and the dependent variable is systolic blood pressure.
All ANOVA tests assume that the groups have equal variance, and variance is a measure of how spread out each individual blood pressure reading is from the group’s mean.
A large variance means that the numbers are very spread out from the mean, like if the mean blood pressure was 130 and the individual measurements included numbers like 112, 142, and 155.
A small variance means that the numbers are very close to the mean, like if the mean blood pressure was 130 and the individual measurements included numbers like 129, 131, and 135.
As a general rule, if one group has a variance that’s more than double another group’s variance, then the variance is unequal.
So, let’s say the variances for the Medication A, B, and C groups are 30, 25, and 36. Since none of the group’s variances is double another group’s, the variance is approximately equal, meaning we can go ahead and do an ANOVA test.
Typically, a one-way ANOVA test starts with two hypotheses. The first one is the null hypothesis, and it says that the means of each group are equal.
In other words, the null hypothesis is that the mean systolic blood pressure is the same for people taking Medication A, B, or C.
The second hypothesis is the alternate hypothesis, and it says that at least one group’s mean is significantly different from the others.
So, the alternate hypothesis in our example is that the mean systolic blood pressure is not the same for people taking Medication A, B, and C.
One important thing to know is that ANOVA doesn’t tell you which group’s mean is different than the others or whether the mean is higher or lower; it simply tells you that the groups’ means are not equal.
Now, there are five steps to test these hypotheses. The first step is to calculate the mean of each individual group and the overall mean or grand mean - which is the mean blood pressure measurements for all the groups.
Since the means for each group are 138, 132, and 130, we can calculate the overall mean by adding up each group - so 138 plus 132 plus 130, which is 400.
Then, we divide that by the number of groups, which is 3. So, the overall mean is 400 divided by 3, or approximately 133.
The second step is to find the between-group variation, which is also called the sum of squares-between, or the SSB. The sum of squares-between is a measure of how similar each group’s mean is to the overall mean.
To find the sum of squares-between, we start by subtracting each group’s mean from the overall mean and squaring it, which is called the squared difference.
Then, you multiply the squared difference by the number of people in that group. So, for Medication A, we subtract the mean blood pressure of the Medication A group, which is 130, from the overall mean, which is 133, and that equals 3.
The squared difference is 3 squared, or 9, and 9 times 10 - which is the number of people in the Medication A group - is 90.
For the Medication B group, the mean is 138, so 133 minus 138 is negative 5, and negative 5 squared is 25. There are 10 people in the Medication B group, so 25 times 10 is 250.
For the Medication C group, the mean is 132, so 133 minus 132 is 1, and 1 squared is still 1. There are 10 people in the Medication C group, so 1 times 10 is 10.
Now that we have the values for each group, we add them together to get the sum of squares-between. So, 90 plus 250 plus 10 is 350.
A larger sum of squares-between tells us that the group means and the overall mean are spread out or different from one another, a smaller sum of squares-between tells us that the group means are fairly similar to the overall mean.
The third step in the ANOVA calculation is to find the within-group variation, which is also called the sum of squares-within, or SSW.
The sum of squares-within is a measure of how similar each individual blood pressure measurement is from its own group mean.
To find the sum of squares-within, you start by finding the squared differences for each person in one group, and to do this, you subtract each individual blood pressure measurement from that group’s mean, then square it.
For example, let’s just take the first 3 systolic blood pressure measurements in the Medication A group, which are 122, 136, and 133.
Since the group mean is 130, you subtract 130 from each individual measurement, so 122 minus 130 is negative 8, 136 minus 130 is 6, and 133 minus 130 is 3.
Then you square each number and add them all together to get the squared difference - so, when you add up negative 8-squared, or 64, and 6-squared, or 36, and 3-squared, or 9, you get 109.
The squared difference is larger for groups with more people, so let’s say the squared difference of the Medication A group is 340, and the the squared differences for the Medication B and C groups are 300 and 275.
As a general rule, if all of the groups have equal sample sizes - like if each group has 10 people - then groups with higher squared differences, like the Medication A group, have more variability than groups that have lower squared differences, like the Medication C group.
In other words, the individual blood pressure measurements for individuals in the Medication A group are more spread out than the blood pressure measurements for individuals the Medication C group.
Now, to get the sum of squares-within, we add up all the squared differences for each group. So 340 plus 300 plus 275 is 915.
The fourth step is to find the mean square of the treatment, or MST, and mean square error, or MSE. The mean square of the treatment is another measure of the variability between groups, but it takes into account the number of groups being tested.
The mean square of the treatment is calculated by dividing the sum of squares-between by its degrees of freedom, which is the number of groups minus 1.
Since the sum of squares-between is 350 and there are 3 groups, the mean square of the treatment is 350 divided by 3 minus 1, or 2.
So 350 divided by 2 is 175. The mean square of the error is another measure of the variability within groups, but it takes into account the number of people in the study and the number of groups in the study.
To calculate the mean square of the error, the sum of squares-within is divided by the sample size in all the groups minus the number of groups in the study.
In this example, there are 30 people and 3 groups. So, since the sum of squares-within is 915, then the mean square of the error is 915 divided by 30 minus 3, or 27, which equals 33.89.
Oftentimes, the mean square of the error is also called the unexplained variability, because it’s the variability that can’t be explained by the independent variable.
As a very simple example, let’s say you choose 2 random people who are taking Medication A; the first person has a systolic blood pressure measurement of 125 and the other has a systolic blood pressure measurement of 130.
Even though both people are taking Medication A, they probably won’t have exactly the same systolic blood pressure, because there will always be some individual variation from characteristics like age, sex, and genetic differences.
On the other hand, the mean square of the treatment is called the explained variability, because it’s the variability that’s explained by or caused by the independent variable.
For example, let’s say you choose 2 people from the Medication B group who have systolic blood pressure measurements of 155 and 150, and we compare them to the 2 people from the Medication A group.
In this case, the lower systolic blood pressure in the first group is probably the result of taking Medication A, since both individuals’ measurements were lower in the Medication A group compared to the Medication B group.
The last step in the ANOVA test is to calculate the F-statistic or F-stat, which is the mean square of the treatment, or the explained variation, divided by the mean square of the error, or the unexplained variation.
In our example, the mean square of the treatment is 175 and the mean square of the error is 33.89, so 175 divided by 33.89 equals 5.16.
An F-stat of 5.16 means that the explained variation is 5.16 times the unexplained variation, which means that the variability we see in systolic blood pressure is likely the result of the medication type and not the result of characteristic differences between individuals.
To figure out if this is a significant F-stat, we have to compare the F-stat to the critical value for the study, which is a predetermined number used to determine whether or not to reject the null hypothesis.
If the value of the F-stat is greater than the critical value, then the null hypothesis is false and we can conclude that there is a significant relationship between medication and blood pressure.
Critical values can be found on an F-distribution table like this one, which has the degrees of freedom for the mean square of the treatment on the top and the degrees of freedom for the mean square of the error on the side.
Typically, the significance level for the F-distribution table is 0.05, or 5%. Using 2 degrees of freedom for the sum of squares-between and 27 degrees of freedom for the sum of squares-within, we find a critical value of 3.35.
The value of our F-stat is 5.16, which is above the critical value of 3.35, so we can reject the null hypothesis and conclude that at least one group’s mean systolic blood pressure is significantly different from the others.
ANOVA tests are most often calculated using statistical software, and the software will often provide a p-value. This p-value is the probability of obtaining a given F-stat or a higher F-stat, if the null hypothesis is true.
In short, the p-value cuts out the step of finding the critical value. So, if we use a significance level of 0.05, then a test with a p-value of less than 0.05 will indicate that the null hypothesis is false and that at least one group’s mean systolic blood pressure is different from the others.
Finally, it’s important to keep in mind that if the assumptions of an ANOVA test are not met, we can’t be sure that the results can be applied to the target population, so an ANOVA shouldn’t be used.
Instead, for a one-way ANOVA, we could use a non-parametric test called the Kruskal-Wallis test, which doesn’t rely on parametric assumptions.
In short, the Kruskal-Wallis test compares the medians of the groups to determine if one of the group’s medians is different than the others, so in this case, if the median blood pressure is different in one group compared to the others.
Parametric tests are generally favoured over non-parametric tests, so the results of the Kruskal-Wallis test are not considered as strong of evidence as the ANOVA test.
Alright, as a quick recap, ANOVA tests are a type of parametric test used to compare the means of multiple groups. Each ANOVA test has a null hypothesis and an alternate hypothesis, and to test these hypotheses we can calculate an F-statistic by dividing the mean square of the treatment by the mean square of the error.
This F-statistic can be compared to a critical value to determine if the means of the groups are equal or not. There are three assumptions, random sampling, independent recruitment, and large sample size or normal distribution, that must be met in order to complete an ANOVA test.
And if these assumptions are not met, the Kruskal-Wallis test can be used to determine if the medians of the groups are equal or not.
No notes for this video yet
Try adding a note below