← 2. Comparing groups

t-Test

A way to judge whether a difference in means is statistically clear once sampling variability is taken into account.

One-sampleIndependent samplesPaired samplesCohen's d

405060708090100Group A 75Group B 827-point gapp = 0.003Test score (points) · 50 per group

Is there a difference in the average test scores of male and female students? Did students who took part in a new education program score higher than before they joined? Does a product's average satisfaction rating differ from 3, the neutral midpoint?

The t-test is the standard method for checking whether a difference in means is statistically significant. It is one of the most widely used statistical hypothesis tests in research papers, surveys, and experimental studies.

It is used in particular to compare the means of two groups, to compare two measurements of the same people, or to compare a sample mean with a specific reference value. In this article we'll look at the basic idea of the t-test, its three main types, a real analysis example, how to interpret the results table, and the assumptions to check before the analysis.

SECTION 1

What is a t-test?

A t-test is a way to judge statistically whether a difference in means observed in a sample could be explained by random sampling variation alone.

For example, suppose 100 students are split into two groups to compare two study methods. Group A uses the existing study method, and group B uses a new one. The test results are:

The two group means differ by 7 points. But the fact that the means differ isn't enough to conclude that the new study method is more effective. Test scores vary from student to student, and the means can also differ depending on how the sample was put together.

The t-test takes this sampling variability into account to judge whether the observed difference in means is statistically significant.

That said, finding a statistically significant difference doesn't necessarily mean the difference matters in practice or that a causal relationship has been proven.

SECTION 2

How does a t-test work?

At its core, a t-test compares a difference in means with the standard error of that difference.

The standard error measures how much an estimate of a mean or a difference in means could vary if you drew samples repeatedly. The general idea of the t statistic is:

t = observed difference in means ÷ standard error of the difference

The actual formula depends on the type of t-test. For example, even if the difference between the two group means is 7 points, it may not be statistically clear if students' scores are very spread out. Conversely, if scores vary little, the same 7-point difference is more likely to come out statistically significant.

Widely spreadLess clearGroup AGroup BTightly clusteredClearerGroup AGroup BDifference 7 pointsDifference 7 points
Spread and the difference in means

The t-test considers this difference and the variability together. In the results, you typically check the following measures.

MeasureMeaning
MeanAverage of a group or sample
Standard deviation (SD)How spread out the observations are around the mean
t statistic (t)The difference in means relative to its standard error
Degrees of freedom (df)The amount of information that determines the t distribution
p-valueThe probability of a result at least as extreme as the one observed, if the null hypothesis is true
Confidence interval (CI)Interval estimate for the population difference in means
Effect sizeA measure that expresses the size of the difference in means in standardized or practical terms
SECTION 3

What types of t-tests are there?

t-tests fall into three main types, depending on what you're comparing and how the data are structured.

MethodWhat is comparedExample use
One-sample t-testOne group's mean vs. a reference valueDoes mean satisfaction differ from 3?
Independent samples t-testMeans of two independent groupsComparing test scores of group A and group B
Paired samples t-testMean difference between two paired measurementsComparing the same students' scores before and after training
One-sample t-testOne group mean vs. a referenceReference value 3Independent samples t-testTwo different groupsGroup AGroup BPaired samples t-testSame subjects, measured twiceBeforeAfter
Three t-tests

All three methods compare means, but the appropriate one depends on how the data were collected.

One-sample t-test

A one-sample t-test checks whether a single sample mean differs statistically from a specific reference value. For example, suppose you want to know whether the mean service satisfaction, measured on a 5-point scale, differs from 3. Here you're not comparing two different groups; you're comparing one sample mean with the reference value of 3.

It is mainly used in situations like these:

Independent samples t-test

An independent samples t-test compares the means of two independent groups. For example, you can apply a different study method to each of two groups made up of different students and then compare their test scores. The students in group A and group B must be different people, and you need to consider the independence of the observations.

There are two common versions of the independent samples t-test.

Consider Welch's t-test especially when the group variances differ or the group sizes are unequal.

Paired samples t-test

A paired samples t-test analyzes the difference between two linked measurements. A typical case is comparing values before and after an intervention in the same people. For example, suppose you measured 30 students' test scores before and after they took part in an education program.

Here you're not comparing two different groups; you calculate each student's before–after difference and test whether the mean difference is 0. The paired samples t-test can be used not only when the same people are measured twice but also when the study design pairs up two observations to compare.

SECTION 4

Real-world example: comparing mean scores for two study methods

Suppose a university split 100 students into two groups to compare the effects of different study methods.

Group A used the existing study method and group B used the new one. Each group had 50 students, and both took the same test after the training. The research question is:

"Is there a difference in mean test scores between the group that used the new study method and the group that used the existing one?"

Descriptive statistics by group

GroupSample size (N)MeanStandard deviation
Existing study method (A)5075.012.0
New study method (B)5082.011.0

Comparing the two group means, group B, which used the new study method, scored 7 points higher on average. But to know whether this difference is statistically significant, you need to look at the t-test results.

Independent samples t-test results

MeasureResult
Mean difference (B-A)7.00
t statistic3.04
Degrees of freedom (df)About 97
p-value0.003
95% confidence interval[2.43, 11.57]
Cohen's d0.61

Rounded results from Welch's independent samples t-test.

50 per group405060708090100Existing study method (A)M = 75.0, SD = 12.0New study method (B)M = 82.0, SD = 11.095% confidence interval for the difference in meansNo difference (0)2.4311.57Observed difference 7.0-202468101214Difference in means (points)t = 3.04p = 0.003d = 0.617.0 points
Score distributions and the 95% confidence interval for the difference in means

How do you interpret the results?

Group B's mean test score was 82, 7 points higher than group A's 75. The t-test gave a p-value of 0.003, smaller than the usual significance level of 0.05. So we can reject the null hypothesis that the two population means are equal and conclude that there is a statistically significant difference in the groups' mean scores.

The 95% confidence interval for the difference in means runs from about 2.43 to 11.57 points and does not include 0. The effect size, Cohen's d, was about 0.61. This means the difference between the two group means is about 0.61 times the pooled standard deviation.

To conclude that the new study method caused the score difference, however, you also need to review the study design, including whether assignment was random, whether the groups differed beforehand, and the learning environment.

SECTION 5

Is a p-value below 0.05 always an important difference?

The value people check most when interpreting t-test results is the p-value.

If you set the significance level at 0.05, you generally call a result statistically significant when p is below 0.05. But statistical significance and practical importance are different concepts. For example, suppose you compared mean satisfaction with two services among 100,000 customers.

Mean satisfaction was 4.20 for service A and 4.22 for service B. With a very large sample, even a small 0.02-point difference can come out statistically significant. But whether a 0.02-point difference matters for running the service has to be judged separately.

Conversely, with a very small sample, even a fairly large difference in means may not be statistically significant. So with a t-test you shouldn't look only at the p-value; check the difference in means, the confidence interval, the effect size, and so on as well.

SECTION 6

What is effect size (Cohen's d)?

Effect size is a measure of how large an observed difference is.

Cohen's d is the effect size most often used with t-tests. For an independent samples t-test, Cohen's d is usually calculated by dividing the difference between the two group means by the pooled standard deviation. The usual guidelines for interpreting it are:

Absolute value of Cohen's dConventional interpretation
0.2Small effect
0.5Medium effect
0.8Large effect
d = 0.2Small effectd = 0.5Medium effectd = 0.8Large effect
Distribution overlap by effect size

These are conventional guidelines proposed by Cohen, not absolute standards that apply equally to every study. In medical research, for example, even a small difference can matter a great deal in practice, while in other fields even a fairly large difference may have little practical importance.

Also, effect sizes can be calculated differently, for example using the standard deviation of the difference scores in a paired samples t-test, so check which measure was used.

SECTION 7

How do t-tests and analysis of variance (ANOVA) differ?

t-tests and ANOVA both analyze differences in means between groups.

The most obvious differences are the number of groups being compared and the design of the analysis.

Groupt-TestAnalysis of variance (ANOVA)
Main purposeComparing a mean with a reference value, or the means of two conditionsAnalyzing mean differences across several groups or factors
Typical comparisonOne group vs. a reference value, two independent groups, two paired measurementsComparing three or more groups, effects of several factors
Main test statistictF
Example useComparing mean scores of men and womenComparing the means of three study methods

For example, to compare the means of two groups you can use an independent samples t-test. To compare the means of three groups that used three different study methods, on the other hand, you might consider one-way ANOVA.

In the standard equal-variance t-test comparing just two independent groups, the square of the t statistic equals the F statistic from a one-way ANOVA with the same design. But you shouldn't tell t-tests and ANOVA apart by the number of groups alone. ANOVA is also used for more complex study designs, such as repeated measures or analyzing the effects of several independent variables together.

SECTION 8

Assumptions to check before a t-test

A t-test should be used with the structure of the data and its statistical assumptions in mind.

The main ones are:

Independence of observations

In an independent samples t-test, the different observations must be independent. For example, treating the same students' before and after test scores as two independent groups ignores the link between the observations. In that case, a paired samples t-test is the right choice.

Normality assumption

The t-test relies on assumptions related to the normal distribution. The one-sample t-test considers normality of the population distribution, and the paired samples t-test normality of the distribution of paired differences. In the independent samples t-test, the population distribution of each group is one of the key assumptions.

That said, if the sample is large enough and there are no extreme outliers, the t-test can work fairly reliably even with some departure from normality.

Equal variances

The standard Student's independent samples t-test assumes the two populations have equal variances. When the variances differ, you can consider Welch's t-test. Because Welch's t-test doesn't require equal variances, it is sometimes used in practice as the default method for comparing independent sample means.

Checking for outliers

Extremely large or small values can change the mean and standard deviation a lot. So it's a good idea to check for outliers before the analysis using box plots, distribution plots, and the like.

But you shouldn't delete observations arbitrarily just because they are outliers. First check whether they are data-entry errors, whether they are values that could really occur, and how much they affect the results.

SECTION 9

What if the normality assumption isn't met?

Failing the normality assumption doesn't necessarily mean you can't use a t-test.

You need to consider the sample size, the shape of the data distribution, the extent of outliers, and so on. But if the data are very skewed or have many extreme outliers so that a mean-based analysis isn't appropriate, you can consider a nonparametric test.

t-TestRelated nonparametric test
One-sample t-testWilcoxon signed-rank test or sign test
Independent samples t-testMann-Whitney U test
Paired samples t-testWilcoxon signed-rank test

Nonparametric tests, however, may not test exactly the same thing as a t-test. For example, the Mann-Whitney U test is basically a test of the distributions or relative location of two groups, and it can be read as a test of a difference in medians only under certain conditions.

So rather than switching methods mechanically based on the p-value of a normality test, consider the research question and the characteristics of the data together.

SECTION 10

How do you report t-test results?

In a research paper or analysis report, rather than just writing that there was a significant difference, it's best to report each group's mean and standard deviation, the t statistic, degrees of freedom, p-value, and so on.

Using the study-method comparison above, you could write it up as follows.

Example results report

Test scores in the group that used the new study method (M = 82.0, SD = 11.0) were significantly higher than in the group that used the existing study method (M = 75.0, SD = 12.0), Welch's t(97.3) = 3.04, p = .003, d = 0.61. The difference between the group means was 7.0 points, with a 95% confidence interval of [2.43, 11.57].

Reporting results this way lets readers see not only whether the result was statistically significant but also which group had the higher mean, how large the difference was, and how uncertain the estimate is. In a real report, it's also best to state clearly which type of t-test was used and how the effect size was calculated.

SECTION 11

Where can you use t-tests?

t-tests are used in many fields where you want to check a difference in means.

Education research

You can compare test scores of two groups taught with different methods, or analyze changes in academic achievement before and after an education program.

Marketing and management

In an A/B test, you can compare the average purchase amount or satisfaction of customer groups that saw different ads or service screens.

Social science research

You can compare different groups' average stress levels, job satisfaction, life satisfaction, and so on.

Health and medical research

You can compare measurements before and after an intervention program, or compare the mean health indicators of two independent groups.

Products and quality control

You can check whether a product's mean weight or measurement differs statistically from a set standard. As these examples show, t-tests can be used, depending on the research aim, to compare with a reference value, to compare two independent groups, or to compare paired measurements.

✓Wrap-up

The t-test is the basic way to check whether a difference in means is meaningful.

A t-test compares a single sample mean with a reference value, or tests the difference in means between two different groups or two paired measurements.


The main types are the one-sample, independent samples, and paired samples t-tests, and the right one depends on how the data were collected and on the study design. And a statistically significant result doesn't necessarily mean the difference is important.

It's important to look at the difference in means, the p-value, the confidence interval, and the effect size together and interpret the results in light of the research aim.

KEY TAKEAWAY

The purpose of a t-test is not simply to see which of two means is higher, but to judge how statistically clear the observed difference in means is once sampling variability is taken into account.