How can I perform a two sample test of means with unequal variances for a very large sample in R?
In case of large samples the statistic will asymptotically follow a normal distribution.
Which R function will help me to do this?
While you can compute the z-statistic, actually an ordinary Welch t-test will do that just fine - in R that's
The form of test statistic is the same in both cases. The only difference is in which table is used, and if the size of the smaller group is large enough, the tests will give almost identical p-values.
The Welch test will handle very large sample sizes.
e.g. in R:
I don't see a problem
The p-values turn out to be the same to all the places shown in the second figure.
If that's not what you want, you need to more carefully explain what you do want.
Example with very different $n$:
Once we're at 99df for the Welch, we start to notice a small difference in p-value from the asympotic result, but since we're at 99d.f., we're not really in the 'consider it as converged to normal' region.
A few points in addition to what @Glen_b makes.
1) The default in t.test is var.equal = FALSE which means it assumes the samples have different variances.
2) I think it is a useful exercise to just skim over the proof of this result in the case of the z-test (involves Slutsky's theorem and the CLT) which you will find online quite easily. Even if all the steps don't make sense (like convergence in distribution for example) it will give you a good sense for why you really care about these degrees of freedom.