 # Comparison of 2 means (independent z test or independent ttest)

In previous articles, I discussed how to calculate the probability of obtaining data as extreme as those we have observed if the null hypothesis were true. This probability, called the P value, was obtained by first calculating the test statistic. We used this information to conduct a 1-sample z test and a 1-sample t test to see whether there is evidence of a difference in age between our sample mean and the hypothesized population mean.

In this article we will compare 2 means using an independent z test or independent t test.

If we have 2 independent groups with continuous normally distributed outcomes, we can compare their means using a z test if the sample is large enough (n > 30) and the population standard error is known, or using a t test if n < 30.

The 2-sample z test is calculated as follows.

z = x ¯ 1 − x ¯ 2 σ 1 2 n 1 + σ 2 2 n 2

where
x ¯ 1
and
x ¯ 2
are the sample means for the first and the second groups, respectively;
σ 1
and
σ 2
are the population standard deviations; and
n 1
and
n 2
are the sample sizes of the respective groups.

In most situations, we assume that the populations have equal but unknown standard deviations: ie,
σ 1 = σ 2 = σ
. When the experimental units are similar (eg, 2 groups of children) and we have observed all factors that might affect the measurements of the subjects, the assumption of equal variances can be considered realistic. In this case, we estimate the common standard deviation :

σ : S = ( n 1 − 1 ) s 1 2 + ( n 2 − 1 ) s 2 2 n 1 + n 2 − 1