Hypothesis Testing: What a p-Value Actually Measures
Published:
The machinery
A test needs three parts. The null hypothesis \(H_0\) is a specific claim precise enough to have a distribution — “the two means are equal” — and the alternative \(H_1\) is its complement, or a directional part of it. The test statistic is a function of the data whose distribution under \(H_0\) is known. You then locate your observed statistic in that null distribution and report how far into the tail it fell.
A two-sample test, all the arithmetic
Two variants of an onboarding flow, measuring time-on-task in seconds. Variant A: \(n_1 = 40\), \(\bar{x}_1 = 52.0\), \(s_1 = 12.0\). Variant B: \(n_2 = 40\), \(\bar{x}_2 = 57.0\), \(s_2 = 14.0\). Test \(H_0: \mu_1 = \mu_2\) against a two-sided alternative.
Pool the two variance estimates, weighting by degrees of freedom:
So \(s_p = \sqrt{170} = 13.038\). The standard error of the difference of means is
and the statistic is \(t = (57.0 - 52.0)/2.9155 = 1.715\) on \(n_1+n_2-2 = 78\) degrees of freedom. The two-sided critical value is \(t^\star_{78} = 1.991\), so at \(\alpha = 0.05\) we do not reject. The exact two-sided p-value is 0.090: under the null, a gap of 5 seconds or more in either direction would arise about 9% of the time. The 95% interval for the difference is \(5 \pm 1.991 \times 2.9155 = [-0.80,\ 10.80]\) — it contains zero, which is the same conclusion in a more informative form.
Errors, and the one people forget
A Type I error rejects a true null; its rate is \(\alpha\), which you choose. A Type II error fails to reject a false null; its rate \(\beta\) you do not choose — it follows from the effect size, the noise and \(n\). Power is \(1-\beta\), the probability of detecting a real effect of a given size.
In the example above, if the true difference really is 5 seconds with \(\sigma \approx 13.0\), then 40 per group gives power of only about 0.40. The study was more likely to miss the effect than to find it. Reaching the conventional 80% would need roughly 107 per group — from \(n \approx 2(z_{0.975}+z_{0.80})^2\sigma^2/\delta^2 = 2(1.96+0.84)^2(170)/25\). Power is decided before the data are collected, and a non-significant result from an underpowered study carries almost no information.
Significant versus meaningful
Statistical significance says an effect is distinguishable from zero; it says nothing about size. Because the standard error shrinks as \(1/\sqrt{n}\), any non-zero effect becomes significant at large enough \(n\). With ten million users, a 0.01% conversion change is detectable and irrelevant. Always report the effect size and its interval, and decide separately whether the magnitude justifies the change.
Many tests at once
Testing \(m\) independent true nulls at \(\alpha = 0.05\), the chance of at least one false positive is \(1 - 0.95^m\): 40% at \(m=10\), 64% at \(m=20\), 99.4% at \(m=100\). Two corrections dominate.
Bonferroni tests each at \(\alpha/m\), bounding the probability of any false positive at \(\alpha\). At \(m=20\) that means a threshold of 0.0025 — safe, and often so conservative that real effects are lost.
Benjamini–Hochberg controls the false discovery rate, the expected fraction of rejections that are false. Sort the p-values \(p_{(1)} \le \dots \le p_{(m)}\), find the largest \(k\) with \(p_{(k)} \le \frac{k}{m}\alpha\), and reject the first \(k\). It is far more powerful when many alternatives are genuinely true, which is why it is standard in genomics and in large feature screens.
p-hacking is what happens when \(m\) is not counted. Trying several metrics, several subgroups, or several stopping points and reporting only the significant one gives a nominal 0.05 test whose real Type I rate is far higher — Simmons, Nelson and Simonsohn (2011) showed that a handful of ordinary, undisclosed analyst choices pushes it above 60%. The defence is to pre-register the primary metric and the sample size.
Recap
- p-value = \(\mathbb{P}(\text{as extreme or more} \mid H_0)\). Never \(\mathbb{P}(H_0 \mid \text{data})\), and never an effect size.
- Worked test: \(s_p^2 = 170\), SE = 2.9155, \(t = 1.715\) on 78 df, \(p = 0.090\), CI for the difference \([-0.80, 10.80]\).
- \(\alpha\) is chosen; \(\beta\) is inherited. That study had ~40% power for the effect it was looking for; 80% would need ~107 per group.
- Large \(n\) makes trivial effects significant — report magnitude and interval, not just the verdict.
- Twenty tests at \(\alpha=0.05\) give a 64% chance of at least one false positive. Bonferroni controls any-false-positive; Benjamini–Hochberg controls the false discovery rate.
References
- Neyman, J., & Pearson, E. S. On the Problem of the Most Efficient Tests of Statistical Hypotheses. Philosophical Transactions of the Royal Society A, 231, 289–337, 1933.
- Wasserstein, R. L., & Lazar, N. A. The ASA Statement on p-Values: Context, Process, and Purpose. The American Statistician, 70(2), 129–133, 2016.
- Benjamini, Y., & Hochberg, Y. Controlling the False Discovery Rate: A Practical and Powerful Approach to Multiple Testing. Journal of the Royal Statistical Society B, 57(1), 289–300, 1995.
- Simmons, J. P., Nelson, L. D., & Simonsohn, U. False-Positive Psychology. Psychological Science, 22(11), 1359–1366, 2011.
