# Two sample Z-Test vs T-Test

A study reports that freshmen at public universities work 10.2 hours a week for pay, on average, and the SD is 8.5 hours; at private universities, the average is 8.1 hours and the SD is 6.9 hours. Assume that the data are based on two independent samples, each size is 1,000. Is the difference between the averages due to chance?

This question is from Freedman book Statistics

We have that the SE is given by $$SE=\frac{\sigma}{\sqrt{n}}$$, so for public universities $$SE=8.5/\sqrt{1000}$$ and for private it's $$SE=6.9/\sqrt{1000}$$

Let $$\mu_1$$ and $$\mu_2$$ be the average work hours for public and private universities then the null hypothesis says that $$H_0:\mu_1-\mu_2=0$$ then under the null hypothesis we have the following statistic

$$z=\frac{\text{observed difference-expected difference}}{SE}$$

the observed difference in this case is $$10.2-8..1=2.1$$ and the SE for the difference is given by $$SE=\sqrt{SE_1^2+SE_2^2}=\sqrt{(\frac{8.5}{\sqrt{1000}})^2+(\frac{6.9}{\sqrt{1000}})^2}\approx 0.35$$

so

$$z=\frac{2.1}{0.35}=6$$

then we can reject the null hypothesis since the chance of we observe a test statistic as extreme as the one we observed is close to 0, so the difference between the sample averages is too big to be chance variation

This question is from a chapter about two sample Z-test so I assumed that the statitic used woule be Normal. The doubts that I have are

Some rules that I saw in different places are i) If you don't known the population standard deviation use the t-test or if you known but the sample size is small (less than 30 observations) also use the t-test instead of the normal test

I want to understand the reasons behind these rules and when they can be ignored, in the exercise I presented above I used the Normal approximation because the sample is too big so the quantiles of t-distribution are close to the normal distribution, so this assumption about known variance can be ignored if I have a big sample size? Why I always can't use the Z-test even when I don't known the variance, why it's important to use the population variance instead of the estimated?

If you performed the $$t$$-test, what would be the resulting test statistic? You will find that it is exactly the same as what you already calculated for the $$z$$-test. The only change is that the $$t$$-test statistic follows a Student's $$t$$-distribution with $$\nu \approx 1917$$ degrees of freedom via the Welch-Satterthwaite approximation

$$\nu = \frac{\left(\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}\right)^2}{\frac{(s_1^2/n_1)^2}{n_1-1} + \frac{(s_2^2/n_2)^2}{n_2-1}},$$ where $$s_1 = 8.5$$, $$s_2 = 6.9$$, and $$n_1 = n_2 = 1000$$. Since the degrees of freedom is so large, the test is effectively identical to a $$z$$-test: the $$p$$-value using the $$t$$-test is

$$p \approx 7.89295 \times 10^{-10}.$$

The $$p$$-value for the $$z$$-test is

$$p \approx 6.56831 \times 10^{-10}.$$

The don't even differ by more than an order of magnitude. In theory, you should use the $$t$$-test, because the standard deviations within each group are derived from the sample. But in practice, not much is gained. The situation would be different if the effect size (i.e. difference between groups) was sufficiently small that the test statistic lay right on the edge of statistical significance, in which case, irrespective of sample size, you would want to use the $$t$$-test to reassure that the test is not erroneously rejecting the null.