# Independent t-test formula

I am trying to understand the independent t-test formula. It is to test if A and B have the same mean, assuming A and B have the same variance. The t is calculated by the following formula:

$$A = A_1, A_2, A_3, ..., A_{n_A}$$

$$B = B_1, B_2, B_3, ..., B_{n_B}$$

$$S = \frac{(n_A-1)s_A^2+(n_B-1)s_B^2}{n_A+n_B-2}$$

$$t = \frac{m_A - m_B}{\sqrt{\frac{S}{n_A}+\frac{S}{n_B}}}$$

Is it possible to use the unbiased variance of A + B instead of the $$S$$?

$$A + B = A_1, A_2, A_3, ..., A_{n_A}, B_1, B_2, B_3, ..., B_{n_B}$$

• Reconsider your premises: That $s^{2}$ in your post is an unbiased estimate of the variance, for two groups that might have different means. Oct 3 at 23:27
• Thank you for pointing it out. What should I use? Tried using $S$ for now Oct 4 at 0:54
• I don't understand your question. What's the problem with using $s^2$? Oct 4 at 1:04

It's a bad idea. If the means in the two groups are different, the variance computed from the two groups combined will include the between-group variation and so will be larger than the true within-group variance $$s^2$$.

For example: two groups of size 30, where A has mean 0 and B has mean 5

> a<-rnorm(30)
> b<-rnorm(30,mean=5)
> var(a)
 0.5855081
> var(b)
 0.858661
> var(c(a,b))
 7.901566


Under the null hypothesis you would still get an unbiased estimator of $$s^2$$, but when the null is false you will overestimate $$s^2$$ and so lose power compared to the standard $$t$$-test