Why Compare Two Groups in Two Ways?
A one-way ANOVA is often introduced as a method for comparing the means of several groups, while a two-sample t test is introduced for comparing two means. When there are exactly two groups, however, the classical one-way ANOVA and the pooled two-sample t test are not competing methods: they are two ways to express the same comparison. Their test statistics satisfy \(F=t^2\).
This identity is useful for understanding both procedures. The t statistic keeps track of the direction of the observed difference: it is positive or negative depending on the order in which the groups are subtracted. The F statistic is nonnegative and records the size of the difference relative to within-group variation. Squaring the t statistic removes its sign, leaving precisely the F statistic.
The result concerns the standard one-way ANOVA and the pooled two-sample t test, which use a common within-group variance estimate. Before using either test for inference, suppose the observations are independent, each group is reasonably described by a normal population, and the two populations have the same variance. The hypotheses for the comparison are \(H_0:\mu_1=\mu_2\) against \(H_a:\mu_1\ne\mu_2\). In examples below, these assumptions are stipulated as part of the hypothetical model; the arithmetic identity itself follows from the formulas.
The Algebra Behind the Identity
Let \(\bar{x}_1\) and \(\bar{x}_2\) be the sample means, and let \(\bar{x}\) be the grand mean across all \(N\) observations. The grand mean is the sample-size-weighted average of the two group means:
For two groups, the between-group sum of squares is \(SSB=n_1(\bar{x}_1-\bar{x})^2+n_2(\bar{x}_2-\bar{x})^2\). Subtracting the grand mean from each group mean gives \(\bar{x}_1-\bar{x}=\frac{n_2}{N}(\bar{x}_1-\bar{x}_2)\) and \(\bar{x}_2-\bar{x}=-\frac{n_1}{N}(\bar{x}_1-\bar{x}_2)\). Substitute these expressions into \(SSB\):
There are two groups, so the between-group degrees of freedom are \(2-1=1\); hence \(MSB=SSB\). The within-group degrees of freedom are \(N-2\), so \(MSW=SSW/(N-2)\). Now square the pooled t statistic. Since \(1/n_1+1/n_2=N/(n_1n_2)\), its squared denominator contains the reciprocal factor needed to match the expression for \(SSB\):
This is an algebraic identity, not an approximation. It holds whether the group sizes are equal or unequal. Because the tests use the same denominator \(MSW\), neither needs a separate estimate of within-group variance.
Worked Example: Balanced Groups
Consider hypothetical measurements from two independent groups of five observations each. Suppose the values are \(8, 9, 10, 11, 12\) in Group 1 and \(10, 11, 12, 13, 14\) in Group 2. For inference, assume the observations are independent and the two groups arise from normal populations with equal variances. Compare the ANOVA and pooled t statistics.
The group means are \(\bar{x}_1=10\) and \(\bar{x}_2=12\). In each group, the deviations from its mean are \(-2,-1,0,1,2\), whose squared deviations sum to \(10\). Thus \(SSW=10+10=20\), and
Using the two-group formula, the between-group sum of squares is
There is one between-group degree of freedom, so \(MSB=10\), and
For the pooled t test, the standard error of the difference is \(\sqrt{MSW(1/n_1+1/n_2)}\). Substitution gives
The negative t value indicates that Group 1’s sample mean is lower than Group 2’s. The ANOVA statistic is \(4\), exactly the square of the t statistic. Both procedures have within-group degrees of freedom \(10-2=8\).
Unequal Group Sizes Still Give the Same Result
Equal sample sizes are not required. The grand mean weights each group mean according to its sample size, which is why the factor in \(SSB\) is \(n_1n_2/N\), not simply one of the group sizes. That factor matches the reciprocal of \(1/n_1+1/n_2\) in the t statistic.
Worked Example: Unequal Group Sizes
Suppose hypothetical independent observations are \(18,19,20,21,22\) in Group 1 and \(19,20,21,22,24,25,26,27\) in Group 2. Assume for inference that the group populations are normal with a common variance. The group sizes are \(n_1=5\) and \(n_2=8\); the sample means are \(\bar{x}_1=20\) and \(\bar{x}_2=23\).
The sum of squared deviations from the first group mean is \(10\). In Group 2 the deviations from \(23\) are \(-4,-3,-2,-1,1,2,3,4\), whose squared deviations sum to \(60\). Therefore \(SSW=10+60=70\), \(N=13\), and
The between-group sum of squares and ANOVA statistic are
For the pooled t test, the standard error is
Consequently,
The exact expressions, evaluated before rounding, agree. The displayed rounded value of \(t\) is only an approximation; squaring a rounded display can produce a slightly different last digit. Here both procedures have within-group degrees of freedom \(11\), and \(F\approx t^2\approx4.352\) to four significant figures.
What the Identity Means for a Test
Under \(H_0:\mu_1=\mu_2\), and under the stated normality, independence, and equal-variance assumptions, the pooled t statistic has a t distribution with \(N-2\) degrees of freedom. The one-way ANOVA statistic under the same null has an F distribution with \(1\) and \(N-2\) degrees of freedom. Squaring a t-distributed random variable with \(N-2\) degrees of freedom gives an F-distributed random variable with \(1\) and \(N-2\) degrees of freedom. Therefore the two-sided t test and the standard upper-tail ANOVA test give the same p-value.
In detail, if the observed t statistic is \(t_{\text{obs}}\), then the two-sided t-test p-value is the probability, under the null, of a t statistic at least as extreme in absolute value: \(P(|T|\ge |t_{\text{obs}}|)\). The ANOVA p-value is the probability of an F statistic at least as large as \(F_{\text{obs}}\). Since \(F_{\text{obs}}=t_{\text{obs}}^2\), these are the same probability. The F statistic does not retain the sign of the difference, so the standard ANOVA test corresponds to a two-sided t alternative, not to a one-sided t alternative.
Worked Example: Same F Statistic, Different Sign Information
Suppose another hypothetical comparison has four observations in each group: \(4,5,7,8\) in Group 1 and \(7,8,10,11\) in Group 2. The means are \(6\) and \(9\), and each group has a within-group sum of squares of \(10\). Assume independent observations from normal populations with equal variances for the inferential comparison.
Here \(SSW=20\), \(N=8\), and \(MSW=20/(8-2)=10/3\). The between-group sum of squares is
The pooled t statistic uses
Squaring before rounding gives \(t^2=9/(5/3)=27/5=5.4=F\). If the order of the groups were reversed, t would be positive instead, but \(t^2\), F, and the two-sided p-value would not change. This illustrates what is gained and lost in the F statistic: it measures evidence against equality of means but does not say which sample mean is larger.
Scope and a Common Mistake
The identity depends on using the pooled t statistic, whose variance estimate is the same \(MSW\) that appears in the classical one-way ANOVA. It does not generally apply to Welch’s two-sample t test, which allows the two population variances to differ and uses a different standard error and degrees-of-freedom calculation. Nor does this identity say that every t test and every ANOVA are interchangeable: it is specifically the two-group, one-way, equal-variance comparison.
A common mistake is to claim that the ANOVA statistic equals \(t\), then use the sign of the t statistic as though it were part of F. The correction is that \(F=t^2\): F is never negative, and it does not encode the direction of the difference. Another mistake is to compare a one-sided t-test p-value with the ANOVA p-value. The standard ANOVA test detects departures in either direction, so its p-value matches the two-sided pooled t-test p-value.
Why use ANOVA at all when there are only two groups? The t test often communicates the estimated difference and its direction more directly. The identity is still valuable because it shows that the two-group case fits coherently within the broader ANOVA framework: both statistics compare between-group separation with the same within-group variability. With more than two groups, the ANOVA F test assesses whether all group means are equal, and no single two-sample t statistic squared represents that overall comparison.
Check Your Understanding
Use the identity and its assumptions to answer these questions.
- For two groups of sizes \(n_1=6\) and \(n_2=9\), what are the ANOVA degrees of freedom, and what are the pooled t-test degrees of freedom?
- If the pooled t statistic is \(2.4\), what is the ANOVA F statistic? What information about the direction of the difference is not contained in F?
- Explain why \(SSB=\frac{n_1n_2}{N}(\bar{x}_1-\bar{x}_2)^2\) leads to \(F=t^2\).
- Why does the standard ANOVA p-value match a two-sided t-test p-value rather than a one-sided t-test p-value?
- Would the identity generally hold for Welch’s t test? Explain which feature of the pooled test makes the identity work.