Can anyone explain why, for an independent two-sample t-test assuming unequal variances, R's t.test
function uses the label "Welch Two Sample t-test," when it appears to use Satterthwaite's 1946 formula for the degrees of freedom (d.f.) calculation?
Specifically, I accessed the body of the t.test
function via getAnywhere(t.test.default)
, and the relevant portions of the code are given below (note the else
is in response to if(var.equal)
, hence it's calculating the d.f. when variances are not assumed equal):
vx <- var(x)
nx <- length(x)
vy <- var(y)
ny <- length(y)
else {
stderrx <- sqrt(vx/nx)
stderry <- sqrt(vy/ny)
stderr <- sqrt(stderrx^2 + stderry^2)
df <- stderr^4/(stderrx^4/(nx - 1) + stderry^4/(ny -
1))
}
I worked out the algebra, and this indeed corresponds to
$$\frac{\left(s_x^2/n_x + s_y^2/n_y\right)^2}{\left(s_x^2/n_x\right)^2/(n_x-1)+\left(s_y^2/n_y\right)^2/(n_y-1)},$$
which was given by Satterthwaite in 1946: "An Approximate Distribution of Estimates of Variance Components". Biometrics Bulletin, 2, 6, pp. 110–114.
Further confusing the issue, the t.test
documentation contains the following statements:
var.equal
: a logical variable indicating whether to treat the two variances as being equal. IfTRUE
then the pooled variance is used to estimate the variance otherwise the Welch (or Satterthwaite) approximation to the degrees of freedom is used.- If
var.equal
isTRUE
then the pooled estimate of the variance is used. By default, ifvar.equal
isFALSE
then the variance is estimated separately for both groups and the Welch modification to the degrees of freedom is used.
In summary:
- R labels its t-test output as if it comes from Welch's theory
- R's documentation talks some about Welch and Satterthwaite, but seems to "lean" toward Welch, yet doesn't give a reference to what it means by "the Welch modification"
- From my calculation, R actually uses Satterthwaite's suggested d.f. calculation
So, which is it - Welch or Satterthwaite? Is Satterthwaite's result being falsely attributed to Welch? Is there something else I'm missing...?