StatisticsInference for Regression and Several Means2 of 3
Inference for Regression and Several Means · 2
One-Way ANOVA
We know how to compare two group averages with a two-sample t-test, and now we want to test whether three or more groups have different population means without running separate tests on every pair.
1
Why ANOVA Compares Means Using Spread
Suppose we compare three study methods (re-reading notes in Group A, flashcards in Group B, and practice tests in Group C) and want to know whether their true population means μA,μB, and μC are equal or whether at least one method has a different mean:
H0:μA=μB=μC
Ha:At least one μ is different
We write Ha in words rather than μA=μB=μC because the population means do not all have to differ from one another to make H0 false. Even if two of the true means are tied at 75 and only the third sits at 88,H0 is already false. Running separate two-sample t-tests on every pair of groups at the 5% level would build up our 5% risk of a false alarm with every test we run, so One-Way ANOVA tests all the groups at once by comparing two kinds of spread.
Why ANOVA Compares Means Using Spread
To judge whether the gap between sample averages is real or just random luck, the F-statistic divides the spread between the group averages by the spread inside the groups:
F=Spread Within Groups (Noise)Spread Between Groups (Signal)
With the group averages fixed at 75,80, and 88, tightly packed scores inside each group keep the within-group noise small and make F large, while widely spread scores overlap across groups and shrink F toward 0.
Even when the group averages stay put, spreading out the dots inside each group grows the noise and shrinks F without changing the signal between groups.
2
Building the F-Statistic from Raw Data
Now we want to turn raw scores into a single number for average signal and a single number for average noise so we can calculate F. We will build both numbers from three groups of 3 students: Group A (2,3,4), Group B (5,6,7), and Group C (8,9,10).
Building the F-Statistic from Raw Data
Text solution
Grand Mean and total spread (SStotal)Across all N=9 people, the overall average (the Grand Mean) is 6, and adding every score's squared distance from 6 gives the Total Sum of Squares.
Noise inside the groups (SSwithin)Adding the squared distances of the scores from their own group averages (xˉA=3,xˉB=6, and xˉC=9) measures how much people vary inside their own group.
Signal between the groups (SSbetween)Replacing each person's score with their group average and adding the squared distances from the Grand Mean of 6 measures how far the groups sit from one another, splitting the total spread cleanly into Signal (SSbetween)54+Noise (SSwithin)6=Total (SStotal)60.
SSbetween=3(3−6)2+3(6−6)2+3(9−6)2=27+0+27=54
Average signal, average noise, and FDividing each sum of squares by its degrees of freedom (dfbetween=k−1 for k=3 groups and dfwithin=N−k across N=9 people) puts the average signal over the average noise.
MSbetween=k−1SSbetween=3−154=254=27
MSwithin=N−kSSwithin=9−36=66=1
F=MSwithinMSbetween=127=27
So the average signal between the three study groups is 27 times the average person-to-person noise inside the groups.
Shifting an entire group's cluster of scores left or right changes the distances between the group averages (SSbetween) while leaving the spacing inside each group (SSwithin) unchanged, and at every position SSbetween+SSwithin equals SStotal.
Sliding whole groups apart or together changes only the between-group signal while the within-group noise stays the same, and the two always add up to the total spread.
3
The F-Distribution and the p-Value
Next, we need to turn F=27 into a p-value: the probability of getting an F-statistic at least this large by random chance when all three study methods actually have the same population mean.
The F-Distribution and the p-Value
When H0 is true, the sample averages differ only because of random person-to-person noise, so the top and bottom of F measure the same random variation:
When H0 is true:F=NoiseNoise≈1
To find the p-value, we look up our test statistic on the F(top dfdfbetween,bottom dfdfwithin) distribution, always listing the numerator degrees of freedom first and the denominator degrees of freedom second.
On the F(2,6) curve, the right-tail area past F=27 is p=0.001<0.05, so we reject H0 and conclude that at least one study method has a different true population mean.
4
Computing ANOVA from a Summary Table
Often we aren't given individual raw scores; instead, we want to compute F from a summary table of group sizes (n), sample means (xˉ), and sample standard deviations (s), often with unequal group sizes.
Even without the raw scores, we can get each group's sum of squares directly from its standard deviation s. Because a sample variance s2 is that group's sum of squares divided by n−1, multiplying s2 by n−1 gives the group's sum of squares back:
s2=n−1Group’s Sum of Squares⟹Group’s Sum of Squares=(n−1)s2
Now let's use this shortcut on N=18 students split unevenly across our three study groups: Group A (nA=4,xˉA=70,sA=5), Group B (nB=6,xˉB=80,sB=4), and Group C (nC=8,xˉC=85,sC=5).
Computing ANOVA from a Summary Table
Text solution
Weighted Grand MeanBecause the groups have different sizes, we weight each group mean by its sample size n to add up all 1440 points across the 18 students rather than taking the simple average of 70,80, and 85.
Between-group mean square (MSbetween)Multiplying each group's squared distance from the Grand Mean of 80 by its group size n and dividing by dfbetween=3−1=2 gives the average signal.
Within-group mean square (MSwithin)Multiplying each group's variance s2 by n−1 gives the sum of squares inside each group, and dividing their total by dfwithin=18−3=15 gives the average noise.
F-statisticDividing the average signal by the average noise gives our test statistic for the F(2,15) distribution.
F=MSwithinMSbetween=22300≈13.64
In the right tail of the F(2,15) curve, the area past F≈13.64 is p=0.0004<0.05, so we reject H0 and conclude that at least one study method has a different true population mean.
Notice two practical details when interpreting and checking an ANOVA test:
Rejecting H0 gives evidence that at least one population mean differs from the others, but it does not tell you which specific pair differs (such as whether Group C beat Group B). Finding out which pairs differ requires follow-up pairwise comparisons.
Because MSwithin=22 is a weighted average of the individual group variances (25,16, and 25), combining them into one noise number requires that the groups have roughly similar spreads in the population, along with independent samples from roughly normal populations.
With the group means fixed at 70,80, and 85 and the group standard deviations fixed at 5,4, and 5, having more students in a group pulls both the Grand Mean balance point and the pooled noise MSwithin toward that group's values.
When study groups have different sizes, the largest group pulls both the Grand Mean and the pooled variance toward its own average and spread.
Key concepts
When you compare the averages of two groups, a single two-sample t-test is all you need. Once you have k≥3 groups, running separate t-tests on every pair builds up the 5% false-alarm risk, so use One-Way ANOVA to test H0:μ1=μ2=⋯=μk against Ha:at least one μ is different in a single right-tailed test (assuming independent samples from roughly normal populations with similar spreads).
ANOVA splits the total squared spread around the Grand Mean into between-group signal and within-group noise:
60SStotal=54SSbetween+6SSwithin
To compare signal and noise fairly across k groups and N total observations, divide each sum of squares by its degrees of freedom (dfbetween=k−1 and dfwithin=N−k) and take their ratio on the F(k−1,N−k) distribution:
When working from a summary table with unequal group sizes (nA=4,nB=6,nC=8), weight each group by n when finding the Grand Mean and SSbetween, and recover each group's sum of squares from its standard deviation using (n−1)s2 (for example, (4−1)(52)=75). An F-value near 1 means the between-group spread looks just like random noise; a large F-value in the right tail gives a small p-value and convincing evidence that at least one population mean is different, though follow-up pairwise comparisons are still needed to tell which specific pairs differ.
5
Practice
1
A researcher wants to compare the average recovery time across 4 physical therapy programs. (a) Why should the researcher run one One-Way ANOVA instead of separate two-sample t-tests for every pair of programs at the 5% significance level? (b) State the null and alternative hypotheses for the ANOVA test, and explain why the alternative is not written as μ1=μ2=μ3=μ4. (c) If the ANOVA test gives p=0.008, what can the researcher conclude at the 5% significance level, and does this test alone tell them whether Program 1 beats Program 2?
For (a), think about what happens to the 5% chance of a false alarm when you run multiple separate tests. For (b), ask whether all four programs have to differ from one another for H0 to be false.
(a) Running separate two-sample t-tests for every pair of programs at the 5% level builds up the 5% risk of a false alarm across the multiple tests, making the overall chance of getting at least one false alarm much higher than 5%. (b) The hypotheses are:
H0:μ1=μ2=μ3=μ4
Ha:At least one μ is different
(Watch out for the common mistake of writing Ha:μ1=μ2=μ3=μ4. The group means do not all have to differ from each other to make H0 false: even if three programs are tied and only one is different, H0 is false.) (c) Because p=0.008<0.05, we reject H0 and conclude that at least one physical therapy program has a different true mean recovery time. However, the ANOVA F-test alone does not tell us whether Program 1 beats Program 2; follow-up pairwise comparisons are needed to tell which specific pairs differ.
2
Two studies each compare 3 teaching methods with 10 students per group (N=30 total). In both studies, the three sample means are 72,78, and 84. In Study 1, scores inside each group stay within 2 points of their group mean; in Study 2, scores inside each group spread 25 points above and below their group mean. (a) Without calculating, which study produces a larger F-statistic and smaller p-value, and why? (b) In a third study with the same design, the researcher finds F=0.96. What does an F-value near 1 indicate, and which F-distribution and tail are used to find the p-value?
Compare the between-group signal and within-group noise in F=NoiseSignal for the two studies, and remember how dfbetween and dfwithin are ordered in F(dfbetween,dfwithin).
(a) Study 1 produces the larger F-statistic and smaller p-value. Both studies have the exact same between-group signal (sample means of 72,78, and 84), but Study 1 has much smaller within-group noise, which makes the ratio F=NoiseSignal much larger. (b) An F-value near 1 indicates that the spread between the group averages is about the same size as the random person-to-person noise inside the groups, which is what we expect when H0 is true. With k=3 groups and N=30 students, dfbetween=3−1=2 and dfwithin=30−3=27. (Be careful not to use N−1=29 for the bottom degrees of freedom or double the tail area for a two-tailed test, which are common mistakes.) Because squared distances make all differences positive, the p-value is the area in the right tail of the F(2,27) distribution.
3
Three fertilizer formulas are tested on 3 plants each, giving the following height gains (in cm): Group A: 1,2,3; Group B: 3,4,5; Group C: 8,9,10. Find the Grand Mean, SStotal,SSwithin,SSbetween,dfbetween,dfwithin,MSbetween,MSwithin, and the F-statistic, and verify that SSbetween+SSwithin=SStotal.
Find each group's average and the Grand Mean across all 9 plants first; when computing SSbetween, remember that we count that group's squared distance from the Grand Mean once for each plant in the group.
The group means are xˉA=2,xˉB=4, and xˉC=9, and the Grand Mean across all N=9 plants is:
Grand Mean=91+2+3+3+4+5+8+9+10=945=5
Adding the squared distances of all 9 plants from the Grand Mean of 5 gives SStotal:
SStotal=(16+9+4)+(4+1+0)+(9+16+25)=84
Inside each group, the squared distances from the group's own mean (xˉA=2,xˉB=4,xˉC=9) are 1+0+1=2, which gives SSwithin:
SSwithin=2+2+2=6
For SSbetween, multiply each group's squared distance from the Grand Mean of 5 by the n=3 plants in that group (forgetting to multiply by n=3 is the likeliest mistake here, which would give 9+1+16=26 instead of 78 and fail the check 26+6=84):
SSbetween=3(2−5)2+3(4−5)2+3(9−5)2=27+3+48=78
Checking the split confirms SSbetween+SSwithin=78+6=84=SStotal. With dfbetween=3−1=2 and dfwithin=9−3=6:
MSbetween=278=39,MSwithin=66=1
F=139=39
4
An experiment compares k=5 diet plans across a total of N=45 participants. The Total Sum of Squares across all 45 participants is SStotal=520, and the Mean Square Within is MSwithin=8. Find dfbetween,dfwithin,SSwithin,SSbetween,MSbetween, and the F-statistic.
Find dfbetween and dfwithin first, then use MSwithin=dfwithinSSwithin to work backwards to SSwithin.
With k=5 groups and N=45 participants, the degrees of freedom are:
dfbetweendfwithin=k−1=5−1=4=N−k=45−5=40
(Watch out for the common mistake of using N−1=44 for dfwithin, which would give SSwithin=352 and F=5.25.) Working backwards from MSwithin=dfwithinSSwithin gives SSwithin, and subtracting from SStotal=520 gives SSbetween:
Dividing SSbetween by dfbetween=4 and taking the ratio gives MSbetween and F:
MSbetween=4200=50
F=850=6.25
5
A study compares exam scores across 3 tutoring formats with unequal sample sizes (N=15): Group A has nA=2,xˉA=56,sA=4; Group B has nB=5,xˉB=66,sB=5; Group C has nC=8,xˉC=76,sC=4. (a) Find the Grand Mean and explain why it is higher than the simple average of the three group means (66). (b) Find SSbetween,dfbetween, and MSbetween. (c) Use the group standard deviations to find SSwithin,dfwithin,MSwithin, and the F-statistic. (d) What condition on the groups' spreads is needed to justify pooling the group variances into MSwithin?
Taking the unweighted average 356+66+76=66 is a common mistake that throws off SSbetween.
Weight each group mean by n to find total points for the Grand Mean, and remember to square each standard deviation s into s2 before multiplying by n−1 to get each group's sum of squares.
(a) Weighting each group mean by its sample size n gives the Grand Mean across all 15 students (taking the unweighted average 356+66+76=66 is a common mistake that throws off SSbetween):
Grand Mean=2+5+82(56)+5(66)+8(76)=15112+330+608=151050=70
The Grand Mean of 70 is higher than the simple average of 66 because Group C has the most students (8) and pulls the overall average toward 76. (b) Weighting each group's squared distance from the Grand Mean of 70 by n gives SSbetween and MSbetween (with dfbetween=3−1=2):
(c) Using Group SS=(n−1)s2 for each group (be careful to square s rather than multiplying n−1 by the unsquared standard deviation s, which would give 1(4)+4(5)+7(4)=52 instead of 228):
(d) Pooling the group variances into a single MSwithin requires that the groups have roughly similar spreads in the population (along with independent samples from roughly normal populations).