# Two-sample t-test

Videos

Notes

## Biostatistics and epidemiology

#### Biostatistics

#### Content Reviewers:

Rishi Desai, MD, MPH#### Contributors:

Elizabeth Nixon-Shapiro, Sarah Clifford, BMBS, BSc (Hons), Marisa Pedron, Kaitlyn HarperThe Student’s t-test or simply, the t-test, is a type of parametric statistical test used to determine if there’s a significant difference between the means or averages of two groups.

And significance is normally defined by a p-value of less than 0.05 or 5%.

Now when doing any parametric test, there are three key assumptions that we have to make about the population.

First, the sample population must have been recruited randomly.

Choosing names randomly ensures that the people included in the study will have similar characteristics to the target population.

This is important because that ensures that the results of the t-test can be applied to the target population - meaning it has good external validity!

The second assumption is that each individual in the sample was recruited independently from other individuals in the sample.

In other words, no individuals influenced whether or not any other individual was included in the study.

For example, if two friends decided to get their blood pressures measured on the same day, and they were both included in the study, these two individuals would not be independent of each other and the second assumption would not be met.

Like random sampling, independent recruitment of individuals is important because it ensures that the sample population approximates the target population.

The third assumption is that the sample size is large enough to approximate the target population, which usually means having more than 20 people.

If it’s impossible to get a large sample size, then the sample population must follow a normal bell-shaped distribution for the characteristic being studied because that’s what we would expect to see in the target population.

Okay, now let’s say you want to figure out if a certain medication lowers systolic blood pressure.

So you find 25 people who have been on the medication for 6 weeks, and figure out that the mean systolic blood pressure for the whole group is 130 mmHg. Then, you find another 30 people who have not been taking that medication, and find out the mean systolic blood pressure for that group is 138 mmHg.

Now, to figure out if a difference in systolic blood pressure from 130 to 138 is significant, we could perform a t-test.

Specifically, since the two means were measured in two different populations, we would use an unpaired or two-sample t-test.

This is different than a paired t-test, which is used to compare the same population before and after the treatment.

For example, a paired t-test could compare the systolic blood pressure measurements of a group of 25 people before using the medication to the systolic blood pressure measurements of the same people after using the medication for six weeks.

Typically, an unpaired t-test starts with two hypotheses.

The first hypothesis is the null hypothesis, and it basically says that the difference in means between the two groups is equal to zero.

In other words, the null hypothesis is that taking the medication results in no difference in systolic blood pressure.

The second hypothesis is the alternate hypothesis, and since a t-test can be either one-sided or two-sided, there are two versions of the alternative hypothesis.

The alternate hypothesis for a one-sided t-test would either state that the difference in means is a positive number or that the difference in means is a negative number.

The alternate hypothesis for a two-sided t-test would state that the difference in means for both groups is not equal to zero, but it wouldn’t specify if it was positive or negative.

Typically, researchers choose to use two-sided t-tests, since they usually don’t know how the medication will affect people who take it.

So, the two-sided alternative hypothesis for our study would state that the difference in means in systolic blood pressure for people that take the medication compared to people who don’t take the medication is not equal to zero.

To test these hypotheses, we need to calculate a t-score, which is a ratio of the difference in means between the two groups to the standard error of the difference in means between the two groups.

Now, for an unpaired t-test, the t-score depends on whether the variance between the two groups is equal or unequal.

Variance is a measure of how spread out each individual blood pressure reading is from the group mean.

A large variance means that the numbers are very spread out from the mean, like if the mean blood pressure was 130 and the individual measurements included numbers like 112, 142, and 155.

A small variance means that the numbers are very close to the mean, like if the mean blood pressure was 130 and the individual measurements included numbers like 129, 131, and 135.

The variance is the square of the standard deviation - which is another measure of how spread out individual values are from the group mean.

As a general rule, if one group has a variance that’s more than double the other group’s variance, then the variance is unequal.

So, if the standard deviation for the no medication group is 12, then the variance would be 12 squared, or 144.

And if the standard deviation for the no medication group is 5, then the variance would be 5 squared, or 25.

Since the variance of the no medication group is more than double the variance of the medication group, the variance is unequal.

Now to calculate the t-score, let’s start with the first part - the difference in means between the two groups.

In our case, that’s the difference in the mean systolic blood pressure for individuals who took the medication and who didn’t take the medication, and it’s represented by the symbol d-bar.

The mean systolic blood pressure for the no medication group is 138 and the mean systolic blood pressure for the medication group is 130, so the difference in means is 8.