Which test, and why: a decision guide for medical data
Contents
Three questions pick the test
Almost every frequentist test in common medical use is determined by three answers:
- What kind of outcome? Continuous, binary, a count, or a time to event.
- How are the observations linked? Independent patients, or the same patient measured twice (paired), or clustered.
- How many groups? One, two, or more than two.
That is the whole decision. The distribution comes in at step 1, not as a property of your numbers but as a claim about the process that produced them.
The distribution is a claim about how the data arose
A common misconception is that you pick a distribution by looking at a histogram. You pick it by asking what generated the number.
dists <- bind_rows(
tibble(family = "Binomial: events out of n\n(responders in 20 patients)",
x = 0:20, y = dbinom(0:20, 20, 0.35), kind = "discrete"),
tibble(family = "Poisson: events per person-time\n(exacerbations per year)",
x = 0:12, y = dpois(0:12, 2.2), kind = "discrete"),
tibble(family = "Normal: a sum of many small effects\n(blood pressure, FEV1)",
x = seq(-4, 4, 0.02), y = dnorm(seq(-4, 4, 0.02)), kind = "continuous"),
tibble(family = "Lognormal: a product of effects\n(CRP, viral load, length of stay)",
x = seq(0.01, 8, 0.01), y = dlnorm(seq(0.01, 8, 0.01), 0.4, 0.7),
kind = "continuous")
)
# Without explicit levels the facets order alphabetically and no longer match
# the order the text walks through them.
dists <- mutate(dists, family = factor(family, levels = unique(family)))
ggplot(dists, aes(x, y)) +
geom_col(data = filter(dists, kind == "discrete"), fill = pal[["blue"]],
width = 0.7) +
geom_area(data = filter(dists, kind == "continuous"), fill = pal[["blue"]],
alpha = 0.75) +
facet_wrap(~ family, scales = "free", nrow = 2) +
labs(title = "Four generating processes behind most medical outcomes",
subtitle = "The question is not what your histogram looks like, but what produced the number",
x = NULL, y = NULL)

Read them as mechanisms:
- Binomial — a fixed number of patients, each either has the event or does not. Response rates, mortality in a fixed cohort, test positivity.
- Poisson — events arriving over time or person-time, with no fixed ceiling. Exacerbations per year, readmissions, falls per 1000 bed-days. The Poisson assumes variance equals the mean, which medical count data almost never honours; see below.
- Normal — a quantity built by adding up many small independent contributions. Most physiological measurements.
- Lognormal — a quantity built by multiplying. Concentrations, titres, durations. These are right-skewed because they cannot go below zero but can go arbitrarily high. Taking logs usually makes them normal, and the difference in log means is a ratio on the original scale.
Two more worth naming: the hypergeometric distribution, which is the exact null of Fisher’s test for a 2×2 table, and the Weibull/exponential family for time-to-event, which I covered in the time-to-event post.
The table
| Outcome | Two independent groups | Paired / before–after | >2 groups | Model that generalises it |
|---|---|---|---|---|
| Continuous | Welch t-test | paired t-test | one-way ANOVA | linear regression |
| Continuous, skewed or heavy-tailed | Wilcoxon rank-sum, or t on logs | Wilcoxon signed-rank | Kruskal–Wallis | regression on logs, or robust/quantile regression |
| Binary | chi-squared, or Fisher if cells are small | McNemar | chi-squared r×c | logistic regression |
| Count | negative binomial, not Poisson | paired analysis / random effect | negative binomial | negative binomial regression with offset |
| Ordinal | Wilcoxon rank-sum | Wilcoxon signed-rank | Kruskal–Wallis | proportional odds regression |
| Time to event | log-rank | — (needs frailty/stratification) | log-rank, k groups | Cox regression |
The right-hand column matters more than it looks. Every test in this table is a special case of a regression model, and the moment you need to adjust for anything — age, baseline severity, centre — you leave the test behind and fit the model. The tests are for the simplest possible question.
Everything below is the part of that table worth arguing about.
Two independent groups: use Welch, always
R’s t.test() defaults to Welch’s version, which does not
assume the two groups share a variance. People routinely override this
with var.equal = TRUE after an F-test of
variances. Here is what that costs.
set.seed(1); B <- 4000
grid <- expand_grid(config = c("n = 30 vs 10", "n = 10 vs 30", "n = 20 vs 20"),
sd_ratio = c(1, 1.5, 2, 3, 4))
welch_row <- function(config, sd_ratio) {
n <- switch(config, "n = 30 vs 10" = c(30, 10),
"n = 10 vs 30" = c(10, 30), c(20, 20))
ps <- pw <- numeric(B)
for (b in 1:B) {
x <- rnorm(n[1], 0, 1); y <- rnorm(n[2], 0, sd_ratio) # null is TRUE
ps[b] <- t.test(x, y, var.equal = TRUE)$p.value
pw[b] <- t.test(x, y, var.equal = FALSE)$p.value
}
tibble(Student = mean(ps < .05), Welch = mean(pw < .05))
}
welch <- grid |>
rowwise() |>
mutate(welch_row(config, sd_ratio)) |>
ungroup() |>
pivot_longer(c(Student, Welch), names_to = "test", values_to = "type_I")
ggplot(welch, aes(sd_ratio, type_I, colour = test)) +
geom_hline(yintercept = 0.05, linetype = "dashed", colour = pal[["grey"]]) +
geom_line(linewidth = 1) + geom_point(size = 2) +
facet_wrap(~ config, nrow = 1) +
scale_colour_manual(values = unname(pal[c("blue", "orange")]), name = NULL) +
scale_y_continuous(labels = scales::percent) +
labs(title = "False-positive rate when the null is true and variances differ",
subtitle = "Dashed line is the nominal 5%. Student's t only misbehaves when group sizes are unequal.",
x = "ratio of standard deviations", y = "type I error")

With equal group sizes Student’s t is fine even when the variances differ by a factor of four. The failure needs both unequal variances and unequal n, and then it is spectacular and goes in both directions:
welch |>
filter(sd_ratio == 4, config != "n = 20 vs 20") |>
pivot_wider(names_from = test, values_from = type_I) |>
mutate(across(c(Student, Welch), scales::label_percent(accuracy = 0.1)))
## # A tibble: 2 × 4
## config sd_ratio Student Welch
## <chr> <dbl> <chr> <chr>
## 1 n = 30 vs 10 4 23.8% 5.0%
## 2 n = 10 vs 30 4 0.3% 4.9%
When the larger group has the smaller variance, the false-positive rate blows up. When the larger group has the larger variance, the test becomes so conservative that it throws away real findings. Welch sits on 5% throughout.
Unequal n with unequal variance is the normal state of medical data — a treated arm and a larger registry control, or a rare disease group against healthy volunteers. Welch costs essentially nothing when variances are equal, so there is no situation in which the extra assumption buys you anything. Leave the default alone, and do not pre-test variances to decide.
Paired and before–after
If the same patient appears twice, the unit of analysis is the difference, not the two measurements. Analysing paired data as two independent groups is the most common serious error in this area, and what it costs depends entirely on how correlated the pair is.
set.seed(2); B <- 4000; n <- 30; delta <- 0.4
paired <- bind_rows(lapply(c(0, 0.3, 0.6, 0.9), function(rho) {
pp <- pu <- numeric(B)
for (b in 1:B) {
u <- rnorm(n) # the patient's own level
pre <- sqrt(rho) * u + sqrt(1 - rho) * rnorm(n)
post <- sqrt(rho) * u + sqrt(1 - rho) * rnorm(n) + delta
pp[b] <- t.test(post, pre, paired = TRUE)$p.value
pu[b] <- t.test(post, pre)$p.value # pretending they are not paired
}
tibble(rho, `paired t-test` = mean(pp < .05),
`treated as independent` = mean(pu < .05))
})) |>
pivot_longer(-rho, names_to = "analysis", values_to = "power")
ggplot(paired, aes(rho, power, colour = analysis)) +
geom_line(linewidth = 1) + geom_point(size = 2.4) +
scale_colour_manual(values = unname(pal[c("blue", "orange")]), name = NULL) +
scale_y_continuous(limits = c(0, 1), labels = scales::percent) +
labs(title = "Power to detect the same real effect, n = 30 patients",
subtitle = "The benefit of pairing is exactly the within-patient correlation",
x = "within-patient correlation between the two measurements",
y = "power") +
theme(legend.position = "bottom")

At zero correlation the two analyses agree, which is the proof that pairing is not a free trick — it buys power only to the extent that patients are consistent with themselves. At a correlation of 0.9, which is routine for repeated spirometry or blood pressure on the same person, the paired test finds the effect 7.3 times as often. Ignoring the pairing here is not a technicality; it is most of your study.
Paired binary: McNemar
The same logic applies to yes/no outcomes, and the mistake is subtler: people lay the data out as a 2×2 table of time against outcome and run a chi-squared test, which silently treats each patient’s two readings as two different people.
To see what that discards, hold the margins identical — 40% positive before, 60% after in every scenario — and vary only how many patients actually changed.
set.seed(5); B <- 4000; n <- 60
# Cells of the (pre, post) table. Marginal difference is p01 - p10, so all three
# scenarios below have exactly the same margins; only the discordance differs.
scenarios <- tribble(
~label, ~p00, ~p01, ~p10, ~p11,
"40% of patients change", .30, .30, .10, .30,
"30% of patients change", .35, .25, .05, .35,
"22% of patients change", .39, .21, .01, .39
)
mc <- scenarios |>
rowwise() |>
mutate({
pr <- c(p00, p01, p10, p11); pm <- pc <- numeric(B)
for (b in 1:B) {
tb <- matrix(as.vector(rmultinom(1, n, pr)), 2, 2, byrow = TRUE)
pm[b] <- tryCatch(mcnemar.test(tb)$p.value, error = function(e) NA)
marg <- rbind(pre = c(n - sum(tb[2, ]), sum(tb[2, ])),
post = c(n - sum(tb[, 2]), sum(tb[, 2])))
pc[b] <- suppressWarnings(chisq.test(marg)$p.value)
}
tibble(McNemar = mean(pm < .05, na.rm = TRUE),
`chi-squared on the margins` = mean(pc < .05))
}) |>
ungroup() |>
select(label, McNemar, `chi-squared on the margins`)
mc |> mutate(across(-label, scales::label_percent(accuracy = 0.1)))
## # A tibble: 3 × 3
## label McNemar `chi-squared on the margins`
## <chr> <chr> <chr>
## 1 40% of patients change 61.6% 53.2%
## 2 30% of patients change 77.0% 53.5%
## 3 22% of patients change 95.0% 54.2%
The chi-squared row barely moves, because the margins never moved — it cannot see the pairing at all. McNemar climbs from 61.6% to 95.0% as the pairing tightens, because it uses only the patients who actually changed, which is where the information is. Same data, same margins, and at the tightest pairing McNemar finds the effect in 95.0% of studies against 54.2%.
Counts: Poisson is usually the wrong default
Exacerbations, readmissions, falls. The Poisson distribution assumes the variance equals the mean, and real clinical counts are overdispersed — some patients are simply frequent exacerbators, so the variance runs well above the mean. Fitting Poisson anyway does not bias the rate ratio much, but it understates its standard error badly.
set.seed(8); B <- 2000; n <- 80
counts <- bind_rows(lapply(c(Inf, 4, 2, 0.8), function(theta) {
pp <- pn <- numeric(B)
for (b in 1:B) {
g <- rep(0:1, each = n / 2) # null is TRUE: no group effect
y <- if (is.infinite(theta)) rpois(n, 2) else rnegbin(n, mu = 2, theta = theta)
pp[b] <- summary(glm(y ~ g, family = poisson))$coef[2, 4]
pn[b] <- tryCatch(suppressWarnings(summary(glm.nb(y ~ g))$coef[2, 4]),
error = function(e) NA_real_)
}
tibble(var_mean = if (is.infinite(theta)) 1 else 1 + 2 / theta,
Poisson = mean(pp < .05),
`negative binomial` = mean(pn < .05, na.rm = TRUE))
}))
counts |> mutate(across(-var_mean, scales::label_percent(accuracy = 0.1)))
## # A tibble: 4 × 3
## var_mean Poisson `negative binomial`
## <dbl> <chr> <chr>
## 1 1 5.4% 4.5%
## 2 1.5 11.2% 5.9%
## 3 2 17.3% 5.9%
## 4 3.5 29.2% 5.2%
At a variance-to-mean ratio of 3.5 — unremarkable for COPD exacerbation counts — the Poisson model calls 29.2% of null comparisons significant at the 5% level. The negative binomial holds its nominal rate throughout, and reduces to the Poisson when there is no overdispersion, so it is the safer default.
Two practical notes: use an offset of log
person-time when follow-up varies between patients, and check
var(y) / mean(y) before believing any Poisson output.
t or Wilcoxon?
The usual framing is that the t-test “requires normality”. That is not quite right, and the simulation says so.
set.seed(6); B <- 4000; n <- 25
# All four generators are standardised to mean 0, SD 1, so a shift of 0.8
# is the same effect size in every row.
gens <- list(
normal = function(k) rnorm(k),
uniform = function(k) (runif(k) - .5) * sqrt(12),
`t, 3 df` = function(k) rt(k, 3) / sqrt(3),
lognormal = function(k) (rlnorm(k, 0, 1) - exp(.5)) /
sqrt((exp(1) - 1) * exp(1))
)
long_label <- c(normal = "normal", uniform = "uniform (light tails)",
`t, 3 df` = "t on 3 df (heavy tails)",
lognormal = "lognormal (skewed)")
tw <- bind_rows(lapply(names(gens), function(nm) {
f <- gens[[nm]]; p0t <- p0w <- pt <- pw <- numeric(B)
for (b in 1:B) {
x <- f(n); y <- f(n)
p0t[b] <- t.test(x, y)$p.value; p0w[b] <- wilcox.test(x, y)$p.value
pt[b] <- t.test(x, y + 0.8)$p.value; pw[b] <- wilcox.test(x, y + 0.8)$p.value
}
tibble(dist = nm,
`type I error` = c(mean(p0t < .05), mean(p0w < .05)),
power = c(mean(pt < .05), mean(pw < .05)),
test = c("t-test", "Wilcoxon"))
}))
tw |>
pivot_wider(names_from = test, values_from = c(`type I error`, power)) |>
rename(`t typeI` = `type I error_t-test`, `W typeI` = `type I error_Wilcoxon`,
`t power` = `power_t-test`, `W power` = `power_Wilcoxon`) |>
mutate(across(-dist, ~ scales::percent(.x, accuracy = 0.1))) |>
as.data.frame()
## dist t typeI W typeI t power W power
## 1 normal 5.0% 5.1% 79.6% 77.8%
## 2 uniform 5.1% 5.1% 78.6% 72.5%
## 3 t, 3 df 4.4% 4.9% 83.6% 94.9%
## 4 lognormal 3.6% 4.9% 82.6% 99.7%
ggplot(tw, aes(reorder(long_label[dist], power), power, fill = test)) +
geom_col(position = position_dodge(0.75), width = 0.68) +
geom_hline(yintercept = 0.05, linetype = "dashed", colour = pal[["grey"]]) +
scale_fill_manual(values = unname(pal[c("blue", "orange")]), name = NULL) +
scale_y_continuous(limits = c(0, 1), labels = scales::percent) +
coord_flip() +
labs(title = "Power to detect the same standardised shift of 0.8 SD",
subtitle = "Both tests held their 5% false-positive rate in every scenario",
x = NULL, y = "power")

Two things to take from this. First, the t-test’s false-positive rate was fine everywhere, including on lognormal data — non-normality at this sample size costs power, it does not invalidate the test. The central limit theorem is about the sampling distribution of the mean, not about your raw histogram.
# Deliberately not a single expression reused with a flipped sign: each gap is
# "the loser's shortfall", so the subtraction order differs between the rows.
gap <- function(d, loser) {
v <- tw |> filter(dist == d)
scales::percent(max(v$power) - v$power[v$test == loser], accuracy = 0.1)
}
Second, the price of choosing wrong is asymmetric. On normal data the Wilcoxon gives up only 1.8% of power. On lognormal data the t-test gives up 17.1%. If you genuinely do not know, the rank test is the cheaper mistake.
The real reason to choose, though, is not power — it is that the two answer different questions. The t-test estimates a difference in means, which is what you want if the outcome is additive and the mean is the clinically meaningful summary. The Wilcoxon tests whether one group’s values tend to exceed the other’s, and pairs naturally with a median or a Hodges–Lehmann shift. For skewed positive quantities a third option is usually best: take logs, run a t-test, and report the result as a ratio of geometric means.
What about testing for normality first?
Standard advice says never to pick your test with a Shapiro–Wilk pretest. I simulated it expecting to reproduce that, and did not.
set.seed(11); B <- 4000
pretest <- bind_rows(lapply(c(8, 12, 20), function(n) {
flag <- logical(B); pt <- pw <- pp <- numeric(B)
for (b in 1:B) {
x <- rlnorm(n, 0, 1); y <- rlnorm(n, 0, 1) * exp(0.9) # a real shift
ok <- shapiro.test(x)$p.value > .05 && shapiro.test(y)$p.value > .05
flag[b] <- !ok
pt[b] <- t.test(x, y)$p.value; pw[b] <- wilcox.test(x, y)$p.value
pp[b] <- if (ok) pt[b] else pw[b]
}
tibble(n_per_group = n, flagged_non_normal = mean(flag),
`always t` = mean(pt < .05), `always Wilcoxon` = mean(pw < .05),
`chosen by pretest` = mean(pp < .05))
}))
pretest |>
mutate(across(-n_per_group, scales::label_percent(accuracy = 0.1))) |>
as.data.frame()
## n_per_group flagged_non_normal always t always Wilcoxon chosen by pretest
## 1 8 71.6% 19.6% 37.0% 35.8%
## 2 12 91.7% 34.8% 52.4% 53.0%
## 3 20 99.6% 57.8% 77.2% 77.2%
On lognormal data the pretest flags the problem 99.6% of the time at 20 per group, and the resulting power matches always-using-Wilcoxon almost exactly. Even at 8 per group it captures nearly all of the benefit (35.8% against 37.0%). I could not make it misbehave, and I am not going to claim a harm I did not observe.
What I would still say is this: decide in advance, because a data-dependent choice is hard to pre-specify in a protocol, and because the choice between a mean difference and a rank comparison is a question about what you want to estimate. A normality test cannot answer that one, however well it performs.
Before–after with a control arm: ANCOVA
A randomised trial measures the outcome at baseline and at follow-up in both arms. There are three obvious analyses, and they are not equivalent.
set.seed(7); B <- 2000; n <- 40 # per arm
ancova <- bind_rows(lapply(c(0.2, 0.4, 0.6, 0.8, 0.9), function(rho) {
p <- matrix(NA_real_, B, 3)
for (b in 1:B) {
arm <- rep(0:1, each = n)
base <- rnorm(2 * n, 50, 10)
fu <- 50 + rho * (base - 50) +
rnorm(2 * n, 0, 10 * sqrt(1 - rho^2)) + 4 * arm
d <- data.frame(arm = factor(arm), base, fu, chg = fu - base)
p[b, 1] <- summary(lm(fu ~ arm, data = d))$coef[2, 4]
p[b, 2] <- summary(lm(chg ~ arm, data = d))$coef[2, 4]
p[b, 3] <- summary(lm(fu ~ arm + base, data = d))$coef[2, 4]
}
tibble(rho,
`follow-up only` = mean(p[, 1] < .05),
`change from baseline` = mean(p[, 2] < .05),
`ANCOVA (adjust for baseline)` = mean(p[, 3] < .05))
})) |>
pivot_longer(-rho, names_to = "analysis", values_to = "power")
ggplot(ancova, aes(rho, power, colour = analysis)) +
geom_line(linewidth = 1) + geom_point(size = 2.2) +
scale_colour_manual(values = unname(pal[c("orange", "green", "blue")]),
name = NULL) +
scale_y_continuous(limits = c(0, 1), labels = scales::percent) +
labs(title = "Three analyses of the same randomised trial, same true effect",
subtitle = "All three are unbiased here; they differ only in how much power they waste",
x = "correlation between baseline and follow-up", y = "power") +
theme(legend.position = "bottom")

ANCOVA wins at every correlation, and the gap between the other two reverses. When baseline and follow-up correlate weakly, subtracting the baseline adds noise and the change score is worse than ignoring baseline altogether; the crossover is around a correlation of 0.5. Adjusting for baseline as a covariate is never the worse choice, which is why it is the standard for trials.
One caveat that matters outside randomised trials: this clean result depends on randomisation. In an observational before–after comparison where the groups differ at baseline, ANCOVA and change scores can disagree substantially and both can mislead — that is Lord’s paradox, and no choice of test resolves it.
What to remember
Three questions settle it: outcome type, pairing, number of groups. The table above is the rest.
A distribution is a claim about mechanism, not a description of a histogram. Ask what produced the number — a fixed denominator, arriving events, a sum, or a product.
Use Welch. Student’s t fails only when unequal variances meet unequal group sizes, which is the ordinary condition of medical data, and then it fails by a factor of four or more in either direction.
If the same patient appears twice, analyse the difference. The power gain equals the within-patient correlation, and at realistic correlations it is most of the study. For binary outcomes that means McNemar, which uses only the patients who changed.
Counts are overdispersed. Negative binomial by default, with an offset for person-time; Poisson only after checking that the variance really does match the mean.
Non-normality costs power, not validity. The t-test held 5% on every distribution I threw at it. Choose between t and Wilcoxon on what you want to estimate — a mean difference or a rank comparison — and consider logs with a geometric-mean ratio for skewed positive outcomes.
In a trial with a baseline, adjust for it as a covariate. Never subtract it and never ignore it.
Every test here is a regression model wearing a disguise. The moment a second variable matters, stop testing and fit the model.