The t-test is the workhorse of thesis statistics: whenever you compare one or two means, it is usually the first tool to reach for. There are three versions, and choosing the wrong one is a classic error in research chapters. This guide works through all three by hand, so you understand exactly what SPSS, R or Python is printing.
The Core Idea
Every t-test has the same structure:
$$ t = \frac{\text{observed difference in means}}{\text{standard error of that difference}} $$
The numerator measures the signal. The denominator measures noise, i.e. how much the difference would bounce around from sample to sample. A large \( |t| \) means the signal is large compared with the noise. We then compare \( t \) with a t-distribution that has a certain number of degrees of freedom (df) to get a p-value.
The t-distribution was published in 1908 by William Sealy Gosset, a chemist at the Guinness brewery in Dublin, under the pen name "Student", which is why it is called Student's t.
Assumptions to Check
- The dependent variable is continuous (interval or ratio).
- Observations are independent (apart from the deliberate pairing in a paired test).
- The data, or the paired differences, are approximately normal. Check with Shapiro–Wilk and a Q–Q plot.
- For the independent test, the two groups have similar variances. Levene's test checks this; if it fails, report Welch's t-test, which does not assume equal variances.
1. One-Sample t-Test
Use it to compare a sample mean with a known or hypothesised value.
Example. A college claims its students average 70 on a standardised English test. A researcher samples 8 students: 72, 68, 75, 80, 70, 77, 74, 78. Is the true mean different from 70?
Step 1: Mean. The sum is 594, so \( \bar{x} = 594/8 = 74.25 \).
Step 2: Standard deviation. The deviations from 74.25 are −2.25, −6.25, 0.75, 5.75, −4.25, 2.75, −0.25, 3.75. Their squares are 5.0625, 39.0625, 0.5625, 33.0625, 18.0625, 7.5625, 0.0625 and 14.0625, which sum to 117.5.
$$ s = \sqrt{\frac{117.5}{8-1}} = \sqrt{16.786} = 4.097 $$
Step 3: Standard error.
$$ SE = \frac{s}{\sqrt{n}} = \frac{4.097}{\sqrt{8}} = \frac{4.097}{2.828} = 1.449 $$
Step 4: t statistic with \( df = n - 1 = 7 \):
$$ t = \frac{74.25 - 70}{1.449} = 2.93 $$
The critical value for a two-tailed test at \( \alpha = .05 \) with 7 df is 2.365. Since 2.93 > 2.365, we reject \( H_0 \); the exact p-value is .022.
Effect size: Cohen's \( d = (74.25 - 70)/4.097 = 1.04 \), a large effect.
APA report: A one-sample t-test showed that students' English scores (M = 74.25, SD = 4.10) were significantly higher than the claimed mean of 70, t(7) = 2.93, p = .022, d = 1.04.
2. Independent-Samples t-Test
Use it when two separate groups of people are compared on the same outcome.
Example. Five students taught with a flipped-classroom method scored 65, 70, 72, 68, 75 on a chemistry test; five taught traditionally scored 60, 62, 66, 64, 58.
Step 1: Group means and variances.
- Flipped: sum 350, \( \bar{x}_1 = 70 \). Squared deviations 25, 0, 4, 4, 25 sum to 58, so \( s_1^2 = 58/4 = 14.5 \).
- Traditional: sum 310, \( \bar{x}_2 = 62 \). Squared deviations 4, 0, 16, 4, 16 sum to 40, so \( s_2^2 = 40/4 = 10 \).
Step 2: Pooled variance.
$$ s_p^2 = \frac{(n_1-1)s_1^2 + (n_2-1)s_2^2}{n_1+n_2-2} = \frac{4(14.5) + 4(10)}{8} = \frac{98}{8} = 12.25 $$
So \( s_p = 3.5 \).
Step 3: Standard error of the difference.
$$ SE = s_p\sqrt{\frac{1}{n_1}+\frac{1}{n_2}} = 3.5\sqrt{0.4} = 3.5 \times 0.6325 = 2.214 $$
Step 4: t statistic with \( df = n_1 + n_2 - 2 = 8 \):
$$ t = \frac{70 - 62}{2.214} = 3.61 $$
The critical value for 8 df is 2.306, so the difference is significant; p = .007.
Effect size: \( d = 8/3.5 = 2.29 \), very large (as is common with tiny made-up samples).
APA report: Students in the flipped classroom (M = 70.00, SD = 3.81) scored significantly higher than those taught traditionally (M = 62.00, SD = 3.16), t(8) = 3.61, p = .007, d = 2.29.
3. Paired-Samples t-Test
Use it when the same participants are measured twice, or when participants are matched in pairs.
Example. Six nursing students took a dosage-calculation test before and after a workshop.
| Student | Before | After | Difference |
|---|---|---|---|
| 1 | 55 | 60 | 5 |
| 2 | 60 | 66 | 6 |
| 3 | 48 | 50 | 2 |
| 4 | 70 | 75 | 5 |
| 5 | 62 | 65 | 3 |
| 6 | 58 | 64 | 6 |
The trick is that a paired test is simply a one-sample t-test on the differences, tested against zero.
Step 1: Mean difference. The differences sum to 27, so \( \bar{d} = 27/6 = 4.5 \).
Step 2: SD of differences. Squared deviations from 4.5 are 0.25, 2.25, 6.25, 0.25, 2.25, 2.25, summing to 13.5.
$$ s_d = \sqrt{\frac{13.5}{5}} = \sqrt{2.7} = 1.643 $$
Step 3: Standard error and t with \( df = 5 \):
$$ SE = \frac{1.643}{\sqrt{6}} = 0.671, \qquad t = \frac{4.5}{0.671} = 6.71 $$
The critical value is 2.571, so the improvement is significant; p = .001.
Effect size: \( d_z = 4.5/1.643 = 2.74 \).
APA report: Dosage-calculation scores improved significantly after the workshop (mean difference = 4.50, SD = 1.64), t(5) = 6.71, p = .001, d_z = 2.74.
Notice why pairing matters: each student's own baseline is removed, so the large differences between students (48 to 70) no longer add noise.
Running t-Tests in Software
- SPSS: Analyze → Compare Means → One-Sample / Independent-Samples / Paired-Samples T Test.
- Excel: the
T.TESTfunction, or the Data Analysis ToolPak. - Stata:
ttest score == 70,ttest score, by(group). - R and Python:
python
from scipy import stats
stats.ttest_1samp(scores, 70)
stats.ttest_ind(flipped, traditional) # add equal_var=False for Welch
stats.ttest_rel(after, before)
Did You Know?
- Guinness did not allow its staff to publish under their own names, which is why Gosset signed his famous paper simply "Student".
- With large samples, the t-distribution becomes almost identical to the standard normal distribution.
- Many statisticians recommend reporting Welch's t-test by default, because it performs well whether or not variances are equal.
Key Takeaways
- One-sample: compare one mean with a fixed value; independent: compare two separate groups; paired: compare two measurements on the same people.
- Every t-test divides a mean difference by its standard error.
- Check normality and, for independent groups, equal variances; use Welch's test when variances differ.
- Report t, df, p and an effect size such as Cohen's d in APA style.
Need your thesis data analysed or a t-test assignment solved step by step? Amathify's statistics experts and PhD scholars are ready to help through WhatsApp or the Ask a Question form.
Stuck on a problem or assignment?
Our experts and PhD scholars solve maths, physics and chemistry — step by step.