The pooled 2-sample t test is equivalent to a
one-way ANOVA with two levels of the factor.
Suppose one level has 10 replications from
$\mathsf{Norm}(\mu_1=1, \sigma_1=10)$ and the other level
has 100 replications from $\mathsf{Norm}(\mu_2=1,\sigma_2=1).$ In the example below,
the pooled t test strongly rejects the null hypothesis
(nominally that $\mu_1=\mu_2)$
with P-value $0.001.$ So the t test must be
'unofficially noticing' the large difference in variances. [Using R.]
set.seed(2021)
x1 = rnorm(10,1,10); x2 = rnorm(100,1,1)
t.test(x1,x2, var.eq=T)$p.val
[1] 0.0009002001
Here is the same test in ANOVA format, showing
the same P-value as above.
x = c(x1, x2)
g = as.factor(rep(1:2, c(10,100)))
anova(lm(x ~ g))
Analysis of Variance Table
Response: x
Df Sum Sq Mean Sq F value Pr(>F)
g 1 98.02 98.018 11.661 0.0009002 ***
Residuals 108 907.84 8.406
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
A brief simulation in R shows that the result
above is not a one-time fluke. The 'power' of the
pooled 2-sample t test, with similar data, is around 50%, (I'm not sure whether @Dave will find it surprising.)
set.seed(1229)
pv = replicate(10^5, t.test(rnorm(10,1,10),
rnorm(100,1,1), var.eq=T)$p.val)
mean(pv <= .05)
[1] 0.53772 # 'power' of test at 5% sig level
The unbalanced pooled t test is notorious for rejecting with
equal means and unequal variances, when the sample
with the larger variance is much smaller. The Welch
2-sample t test is designed to mitigate this
kind of bad behavior, rejecting at the 5% level about 5%
of the time when means are equal, even when variances are not.
set.seed(1229)
pv = replicate(10^5, t.test(rnorm(10,1,10),
rnorm(100,1,1))$p.val)
mean(pv <= .05)
[1] 0.0493
The bad behavior continues for unbalanced one-way
ANOVAs, when means are equal and one level has
much larger variance along with small sample size.
One instance with three levels is shown below;
the hull hypothesis is rejected, even though the three population means are equal.
set.seed(2021)
x1 = rnorm(10, 1, 10)
x2 = rnorm(100, 1, 1)
x3 = rnorm(100, 1, 1)
x = c(x1,x2,x3)
g = as.factor(rep(1:3, c(10,100,100)))
anova(lm(x~g))
Analysis of Variance Table
Response: x
Df Sum Sq Mean Sq F value Pr(>F)
g 2 98.15 49.074 10.027 6.975e-05 ***
Residuals 207 1013.08 4.894
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
However, the procedure oneway.test
in R does not
require equal variances, using a Welch-like reduced
denominator degrees of freedom to the extent that sample variances are unequal. This test
does not find significant differences among the three means.
oneway.test(x~g)
One-way analysis of means
(not assuming equal variances)
data: x and g
F = 1.9742, num df = 2.000, denom df = 22.981, p-value = 0.1617