Guides  /  t test

T-tests: a complete guide, with worked examples

The t-test is the first inferential test most researchers meet and the one most often reported incorrectly. This guide covers the three types and when each applies, the assumptions and what to do when they fail, two worked examples calculated by hand, effect sizes, and exactly how to report the result in APA style.

Hafiz Ahmad Tariq Written and reviewed by Hafiz Ahmad Tariq, Senior Biostatistician
Updated 14 August 202619 min read
What is a t-test?

A t-test is a statistical test that compares means to determine whether an observed difference is larger than would be expected by chance. There are three types: a one-sample t-test compares a sample mean to a known value, an independent samples t-test compares two separate groups, and a paired samples t-test compares two measurements from the same participants.

Definition

What a t-test does

A t-test compares means and asks whether the difference between them is larger than chance alone would comfortably produce. It does this by expressing the difference as a ratio: how big the difference is, divided by how much variability there is in the data.

Because it is a ratio, the same difference between two means can produce a large or a small t depending entirely on how noisy the data are. Two studies reporting an identical four-point difference can reach opposite conclusions, and neither is wrong — the one with tighter data simply has stronger evidence that the difference is real. This is why reporting a difference without its variability tells a reader almost nothing, and why the standard deviation belongs in every results table alongside the mean.

That ratio is the t statistic. A large t means the difference is big relative to the noise; a small t means the difference could easily be noise. The p-value then tells you how often you would see a t that extreme if there were genuinely no difference at all.

−2.01 +2.01 t = 3.31 t distribution, df = 48 Shaded = the 5% most extreme results if the null were true Your t falls beyond the critical value, so p < .05. That is all significance means — not that the effect is large or important.
With df = 48 the critical value is about ±2.01. An observed t of 3.31 falls in the shaded region, so p < .05.
What significance does not mean

A significant t-test does not mean the difference is large, important, or caused by your intervention. It means a difference this size is unlikely to arise by chance. Size is the effect size’s job; importance is yours; causation is the design’s.

Choosing

The three types, and which you need

TypeComparesExampleCalculator
One-sampleOne sample mean against a known or hypothesised valueIs our cohort’s mean score different from the national average of 50?
Independent samplesTwo separate groups of different peopleDo the intervention group and control group differ?effect size calculator
Paired samplesTwo measurements from the same peopleDid scores change from before to after?

The distinction between independent and paired is where most errors happen, and it is not about the data layout — it is about the design. If each row of your dataset is one person measured twice, you need a paired test. If each row is a different person, you need an independent test.

Using the wrong one is not a small error

A paired design analysed with an independent test throws away the pairing, which is usually the most powerful feature of the design. It typically makes a real effect disappear, and an examiner will spot it from the methods section alone.

When a t-test is not the right test

Three or more groups — use ANOVA. Running multiple t-tests inflates your false positive rate
An ordinal outcome — consider Mann-Whitney U or Wilcoxon signed-rank
A categorical outcome — use chi-square or logistic regression
More than one predictor — use regression
Clustered data — students in classes, patients in wards — use a multilevel model

Assumptions

Assumptions, and what to do when they fail

Every parametric test rests on assumptions. Reporting that you checked them is the single most common omission in a results chapter, and it is also the quickest to fix.

AssumptionHow to checkIf it fails
Outcome is continuousBy inspection of the variableUse a test for ordinal or categorical data
Observations are independentBy the design, not a testUse a paired test, or a multilevel model for clustering
Approximate normalityShapiro-Wilk; Q-Q plot; skew and kurtosisMann-Whitney U (independent) or Wilcoxon (paired). Or rely on the central limit theorem if n is large
Equal variances (independent only)Levene’s testUse Welch’s t-test — and see below
No extreme outliersBoxplot; standardised residualsInvestigate before removing. Report the analysis with and without

Normality: the assumption people over-worry about

The t-test assumes the sampling distribution of the mean is approximately normal, not that your raw data is. With samples above roughly 30 per group, the central limit theorem makes this reasonable even for fairly skewed data. Shapiro-Wilk is also over-sensitive in large samples, flagging trivial departures as significant.

Practical guidance: inspect a Q-Q plot as well as running a test, and treat a significant Shapiro-Wilk in a large sample as information rather than an instruction.

Equal variances: just use Welch

The classic advice is to run Levene’s test and switch to Welch’s correction if it is significant. The modern recommendation is simpler: use Welch’s t-test by default. It performs as well as Student’s when variances are equal and considerably better when they are not, so the two-step procedure adds a decision without adding accuracy.

SPSS reports both rows in its output. R’s t.test() uses Welch by default, which is why R and SPSS sometimes disagree until you notice which row you read.

Not sure whether your assumptions hold?

Send the dataset and a statistician will check the assumptions, run the right test, and give you the annotated output plus the syntax — so you can rerun it and defend it.

See SPSS data analysis

Worked example

Worked example: independent samples

A study compares reading scores between an intervention group and a control group.

GroupnMeanSD
Intervention4824.65.2
Control4521.14.9

Step 1 — the pooled standard deviation

Combine the two groups’ variability, weighted by their sample sizes:

sp = √[ ((n₁−1)s₁² + (n₂−1)s₂²) / (n₁+n₂−2) ]
= √[ (47 × 27.04 + 44 × 24.01) / 91 ] = √25.62 = 5.06

Step 2 — the standard error of the difference

SE = sp × √(1/n₁ + 1/n₂) = 5.06 × √(1/48 + 1/45) = 5.06 × 0.2075 = 1.050

Step 3 — the t statistic

t = (M₁ − M₂) / SE = (24.6 − 21.1) / 1.050 = 3.5 / 1.050 = 3.33, with df = n₁ + n₂ − 2 = 91.

Step 4 — the p-value and the decision

At df = 91 the two-tailed critical value at α = .05 is about ±1.99. Our t of 3.33 exceeds it comfortably, giving p = .001. We reject the null hypothesis of no difference.

Step 5 — the effect size, which is not optional

d = (M₁ − M₂) / sp = 3.5 / 5.06 = 0.69 — a medium-to-large effect by convention. The 95% confidence interval for d is [0.27, 1.11], which excludes zero and is consistent with the significance test.

Check it yourself

Our effect size calculator takes exactly these six numbers and returns Cohen’s d with its confidence interval, Hedges’ g, and the APA sentence.

Worked example

Worked example: paired samples

The paired test works on the differences, not the raw scores — which is why it is more powerful when the pairing is real.

ParticipantBeforeAfterDifference
P11823+5
P22224+2
P31521+6
P420200
P51722+5
P61925+6

Mean difference Md = 4.0, standard deviation of the differences sd = 2.28, n = 6.

SE = sd / √n = 2.28 / 2.449 = 0.931
t = Md / SE = 4.0 / 0.931 = 4.30, df = n − 1 = 5, giving p = .008.

Effect size for a paired test is dz = Md / sd = 4.0 / 2.28 = 1.75.

Why the paired test found this with six people

Between-person variability is removed entirely. Scores ranged from 15 to 25, but the differences ranged only from 0 to 6 — and it is that smaller variability the test divides by. Analysed as independent groups, this same data would not have come close to significance.

Worked example

Worked example: one-sample

The one-sample t-test is the simplest of the three and the one most often forgotten. It compares your sample mean against a value you already know — a national average, a published benchmark, a clinical threshold, a target set by a funder.

A department reports a mean student satisfaction score of 4.18 (SD = 0.62) from 40 respondents. The sector benchmark is 4.00. Is the department genuinely above benchmark, or is 4.18 within the range you would expect from 40 people by chance?

SE = s / √n = 0.62 / √40 = 0.62 / 6.325 = 0.098
t = (M − μ) / SE = (4.18 − 4.00) / 0.098 = 1.84, df = n − 1 = 39.

At df = 39 the two-tailed critical value is about ±2.02. Our t of 1.84 does not reach it, giving p = .073. The difference is in the expected direction but not statistically significant.

This is where &ldquo;approaching significance&rdquo; gets written

Resist it. The honest report is that the department scored above benchmark by 0.18 points, t(39) = 1.84, p = .073, d = 0.29 — a small effect that this sample was too small to distinguish from chance. That is a finding, and it is more useful than a phrase that implies the threshold nearly moved.

Effect size here is d = (M − μ) / s = 0.18 / 0.62 = 0.29. Note how much more the effect size tells you than the p-value: the department is above benchmark by roughly a third of a standard deviation, and a larger sample would settle whether that is real.

Non-parametric options

When the assumptions fail: the alternatives

If normality is genuinely violated in a small sample, the standard alternatives compare ranks rather than means. They answer a slightly different question, and that difference matters when you write up.

Parametric testNon-parametric alternativeWhat it actually compares
Independent samples tMann-Whitney UWhether one group tends to score higher, by ranks
Paired samples tWilcoxon signed-rankWhether the differences tend to be positive or negative
One-sample tOne-sample WilcoxonWhether the median differs from a value

The important nuance: Mann-Whitney does not test whether the means differ, and describing it as if it did is a common slip. It tests whether values from one group tend to exceed values from the other. Where the two distributions have a similar shape, that is close to a median comparison; where they do not, it is a statement about stochastic dominance and should be worded carefully.

Reach for non-parametric when

  • Small samples with clear, visible skew
  • The outcome is genuinely ordinal
  • There are extreme outliers you cannot justify removing
  • Your discipline expects it for this measure

Stay parametric when

  • Samples are reasonably large — roughly 30+ per group
  • Shapiro-Wilk is significant but the Q-Q plot looks fine
  • You need the effect size and confidence interval a t-test gives
  • You will later extend the analysis to regression or ANOVA
Non-parametric is not automatically the safe choice

It discards information by converting values to ranks, which usually costs power, and effect sizes are less familiar to readers. Switching only because Shapiro-Wilk flagged a large sample is a common over-correction.

Whichever you use, report it consistently: the test statistic, the exact p-value, and an effect size — r = z/√N for Mann-Whitney and Wilcoxon.

Effect size

Effect size — the part people omit

Significance tells you an effect probably exists. Effect size tells you how big it is, and it is the question anyone reading your work asks next. APA has required it for years and reviewers routinely send papers back without it.

StatisticUse forConventional bands
Cohen’s dIndependent samples0.2 small · 0.5 medium · 0.8 large
Hedges’ gIndependent samples, n < ~50Same bands; corrects small-sample bias
Cohen’s dzPaired samplesSame bands, but not comparable to independent d
Cohen&rsquo;s bands were offered as conventions, not thresholds

Cohen said so himself, and warned against exactly the mechanical use they now get. In a field where interventions typically move an outcome by d = 0.15, a d of 0.3 is a substantial result. Judge magnitude against your literature, not a table.

Report the confidence interval around the effect size as well as the point estimate. It carries far more information than the p-value: an interval of [0.27, 1.11] tells the reader the effect is probably real but its size is still uncertain, which a bare p = .001 conceals.

APA 7

Reporting a t-test in APA style

The complete form, with every element APA 7 expects:

t(91) = 3.33, p = .001, d = 0.69, 95% CI [0.27, 1.11]

Written into a results section, with the descriptive statistics that give it meaning:

A model sentence

The intervention group (M = 24.6, SD = 5.2) scored significantly higher than the control group (M = 21.1, SD = 4.9), t(91) = 3.33, p = .001, d = 0.69, 95% CI [0.27, 1.11].

Statistics italicised: t, p, d, M, SD
Degrees of freedom in brackets immediately after t
Exact p to three decimals; below .001 report p < .001, never p = .000
No leading zero on values that cannot exceed 1 — p = .001, not 0.001
Means and SDs reported so the reader can see the actual difference
An effect size, with its confidence interval
If you used Welch’s correction, say so — and note the fractional df it produces
Get the formatting right automatically

Our APA results generator takes your values and returns the correctly formatted line for eight different tests, including both t-tests.

Open the APA generator

Common problems

Seven mistakes that cost marks

MistakeWhy it mattersInstead
Independent test on a paired designDiscards the pairing and usually hides a real effectMatch the test to the design, not the spreadsheet
Multiple t-tests instead of ANOVAThree tests at α = .05 give roughly a 14% false positive rateUse ANOVA, then post-hoc tests with correction
p = .000No p-value is zero; it is a rounding artefactp < .001
No effect sizeSignificance without magnitude answers half the questionReport d or g with its CI
Assumptions never mentionedThe reader cannot judge whether the test was validState what you checked and what you found
“Approaching significance” at p = .06The threshold is arbitrary but the language is notReport the exact p and the effect size, and let them speak
Causal language from a correlational designThe test cannot support it“Associated with”, unless you randomised

Answers

Frequently asked questions

What is the difference between a paired and an independent t-test?

An independent samples t-test compares two separate groups of different people. A paired samples t-test compares two measurements taken from the same people — before and after, or two conditions completed by everyone. The distinction is about your design, not how the data is laid out.

What does the t value actually mean?

It is the size of the difference divided by the standard error of that difference. A t of 3 means the observed difference is three times larger than the typical sampling variability, which makes chance an unconvincing explanation.

How many participants do I need for a t-test?

It depends on the effect you want to detect. To find a medium effect (d = 0.5) with 80% power at α = .05 you need about 64 per group for an independent test. A power analysis before data collection gives the answer for your specific design.

Can I run a t-test on Likert data?

With a single Likert item, usually not — it is ordinal with few categories, so Mann-Whitney U is safer. With a summed multi-item scale, a t-test is generally accepted, though you should say why you treated the total as continuous.

What if my data is not normally distributed?

With reasonably large samples the t-test is robust, because the central limit theorem applies to the sampling distribution of the mean rather than to your raw data. With small or heavily skewed samples, use Mann-Whitney U for independent data or Wilcoxon signed-rank for paired data.

Should I use a one-tailed or two-tailed test?

Two-tailed, almost always. A one-tailed test is only justified when a difference in the opposite direction would be meaningless and you committed to that before seeing the data. Switching to one-tailed after a two-tailed result misses significance is a recognised questionable research practice.

Why do SPSS and R give slightly different results?

R's t.test() uses Welch's correction by default; SPSS reports both rows and people commonly read the Student's row. The Welch result has fractional degrees of freedom, which is the usual giveaway.

Do I have to report an effect size?

Yes, in practice. APA has required it for years, and reviewers and examiners routinely ask for it. Report Cohen's d or Hedges' g with a confidence interval.

Send the data. Get a fixed quote.

Attach your dataset or just describe the project. A named statistician replies with a price and a deadline, usually within one working day.