Ways to break a p-value

When there is nothing to find, a valid test's p-value is equally likely to land anywhere between 0 and 1. Its histogram is flat, and it falls below 0.05 one time in twenty: that is what makes a threshold of 0.05 a 5% false-positive rate. Each panel below makes data in which nothing is going on, analyses it two ways, a common shortcut and a sound alternative, and shows what the shortcut does to the flat histogram and to the share of p-values below the threshold.

1 Regressing out the batch first

Samples are processed in batches, and each batch shifts every measurement a little. A common fix is done in two steps: estimate the batch effects, subtract them from the outcome, then test the treatment on what is left. Fitted in one model, the test knows that k − 1 batch effects were estimated from the same data; in two steps it does not, so its residual variance is too small and its t too large. When the treatment is spread unevenly over the batches, the second step also forgets that the batch took part of the treatment's variance, and the error grows.

Even-numbered batches have the rest treated. 0.5 balances the treatment across batches.

2 Covariates removed one at a time

Instead of one model with every covariate, an analysis can remove the covariates one at a time: regress the outcome on the treatment and one covariate, subtract that covariate's part, and go on to the next. Here each covariate is pure noise. Every step removes a little of the outcome's residual variation, so the final standard error shrinks, and every step also moves the treatment's coefficient by a random amount the final model never hears about. Rescaling the residual variance for the k extra parameters undoes the first but not the second.

Final test

3 A t-test on bootstrap means

The bootstrap resamples each group's data with replacement and recomputes its mean, B times. The spread of those B means estimates the standard error of the group's mean. A t-test on the bootstrap means treats them as B independent observations and divides that standard error by √B once more, so the more resamples, the smaller the p-value, whatever the data say. Comparing the two groups' bootstrap distributions directly, by the share of resampled differences above 0, gives a p-value close to uniform.

4 Correlating autocorrelated series

Two series measured over time, or along a genome, are each autocorrelated: neighbouring points are alike. The usual test of their correlation assumes n independent pairs. With autocorrelation each series holds fewer independent pieces of information, so the correlation of two unrelated series varies more than the test allows (for two AR(1) series with coefficient φ, (1 + φ²)/(1 − φ²) times as much) and the p-values pile up near 0. Fisher's z makes the same assumption. The panel compares three remedies: an effective number of observations, a test against circular shifts of one series, and a Newey–West standard error.

Test assuming independence
Remedy

5 An interaction tested where one group found an effect

A two-step analysis tests each variant's effect on an outcome separately in two groups, keeps the variants that pass a false-discovery cut in either group, then tests the kept ones for a difference between the groups, an interaction. Here every variant has the same small effect in both groups, so there is no interaction to find. A variant passes the first step mostly when its estimate in one group came out high by chance, so the kept variants are those whose two estimates differ, and the interaction test duly finds the difference. Filtering on the pooled effect instead, which does not depend on that difference, leaves the interaction's p-values uniform.

6 Paired data tested as independent

Measure the same people before and after. People differ from each other far more than they change, so each person's two values are strongly correlated. A two-sample t-test ignores the pairing and charges the comparison for the whole spread between people. Under a true null its p-values crowd towards 1 and it almost never rejects; with a real change it misses most of them. The paired test works on each person's change and is exact. Set a true mean change to compare their power.

0 is the null. Anything else makes rejections true positives, so the rates become power.

7 Keeping only pathways with a hit

Enrichment analysis asks whether a pathway holds more of the differentially expressed (DE) genes than chance would put there, by a one-sided hypergeometric (Fisher) test. When the DE genes are random, most pathways hold none, and their p-value is exactly 1. The test is discrete, and with so few hits expected it is very conservative. Dropping the empty pathways before correcting for multiple testing looks harmless, but it selects on the outcome: given at least one hit, a small pathway's p-value is already below 0.05.

Pathway sizes are equally likely between the two.

The histograms are exact. The Benjamini–Hochberg counts come from one simulated sample.

How it works

Reading the figures

Each histogram shows one analysis's p-values in 20 bins, as a density, so a valid test's bars stand at height 1 (the dashed line). The plot below them shows, for every threshold from 10⁻⁴ to 1, the share of p-values at or below it. A valid test lies on the diagonal; a curve above it rejects a true null more often than its threshold promises, and one below it is conservative and loses power. The vertical line is α, and the marks on it are the two analyses' false-positive rates.

Exact and simulated

Where the null distribution has a closed form it is used, and the figure is exact: the batch panel, the joint model of the second panel and the enrichment panel. Elsewhere the data are simulated with a seed, so the same seed gives the same p-values for the same settings; each rate there carries its Monte Carlo standard error, and the panel says how many replicates it ran. More replicates narrow the error. Simulations run in a background worker, so the page stays responsive. The API provides the same computations.

Regressing out the batch

Regressing the outcome on the treatment and the k − 1 batch indicators, then refitting the outcome minus the fitted batch effects on the treatment alone, gives the same coefficient and the same residuals. Only the standard error differs: the refit divides the residual sum of squares by n − 2 instead of n − k − 1, and uses the treatment's whole variance instead of the part the batches leave, 1 − R². So its t is the model's times √((n − 2)/(n − k − 1)) / √(1 − R²), and since the model's t has exactly a t distribution on n − k − 1 degrees of freedom, the shortcut's false-positive rate is exact.

Filtering

The two-step and enrichment panels break the same rule from opposite ends: a filter applied before testing keeps the test valid only if, under the null, it is independent of the test statistic (Bourgon, Gentleman and Huber, PNAS 2010). Significance in one group is not independent of the difference between groups, and having at least one hit is not independent of the hit count. The pooled effect is, nearly: with equal designs in the two groups the pooled slope and the difference of the slopes are independent, and they share only the residual variance.