Skip to main content

Try it in R: The Statistical Significance Filter

Noise and evidence
Intermediate
Simulate Type M (exaggeration) and Type S (wrong-sign) errors when noisy studies are filtered by p < 0.05.
Published

November 11, 2026

Modified

November 15, 2026

Lab 1 of 4 · Companion to entry #32: The Statistical Significance Filter All R labs · Next: Lab 2 (16) →

When a study is noisy, only the estimates that happen to come out large clear the \(p < 0.05\) bar (\(|\hat\theta| > 1.96\,\text{se}\)). This lab builds Gelman and Carlin’s (2014) design analysis from scratch in base R so you can measure how much the significance filter exaggerates true effects (Type M error) and how often it flips their sign (Type S error).

Step 1: One study, replicated 400 times

Suppose a treatment has a true effect of theta <- 0.2, and each study estimates it with standard error se <- 0.25. At this noise level, the study has only 13% power. Run the code below, then try the three experiments underneath it.

Predict → Modify → Observe

  1. Shrink the true effect. Before editing, predict: if you cut theta from 0.2 to 0.05 (keeping se <- 0.25), will the average significant estimate avg_sig drop toward 0.05? Change theta <- 0.05 on line 2 and click Run Code. Notice that avg_sig stays stuck above 0.50—because the significance threshold 1.96 * se = 0.49 sets a hard floor on what can be called “significant”, inflating the exaggeration ratio past \(10\times\).
  2. Count the wrong-sign “discoveries”. At theta <- 0.05, check the last printed line: how many statistically significant estimates point in the opposite direction of the true effect?
  3. Shrink the noise instead. Keep theta <- 0.2 and lower se from 0.25 to 0.07 (which requires \((0.25 / 0.07)^2 \approx 13\) times as many participants). Watch how the gray dead-zone narrows and the exaggeration ratio drops near 1.1x.

Step 2: How exaggeration grows as power falls

One batch of 400 replications has Monte Carlo noise. Gelman and Carlin’s design analysis computes the expected exaggeration ratio across a whole grid of plausible true effects thetas for a fixed standard error se = 0.25.

Your turn: compute the exact Type S (wrong-sign) rate

When \(\theta > 0\) and \(\hat\theta \sim \mathrm{N}(\theta, \text{se}^2)\), you don’t even need random numbers to find the Type S error rate—the probability that a statistically significant estimate is negative (\(\hat\theta < -1.96\,\text{se}\)).

Complete the function type_s(theta, se) below using pPos (the chance of a significant positive estimate) and pNeg (the chance of a significant negative estimate), then compute the Type S rate when theta = 0.1 and se = 0.25.

An estimate is significant with Probability p_pos + p_neg, and it has the wrong sign (negative when theta > 0) with probability p_neg. Divide p_neg by the total probability of significance p_pos + p_neg.

type_s <- function(theta, se) { p_pos <- 1 - pnorm(1.96 - theta / se) # Pr(est > +1.96 * se) p_neg <- pnorm(-1.96 - theta / se) # Pr(est < -1.96 * se) p_neg / (p_pos + p_neg) } # At theta = 0.1, se = 0.25, ~9% of significant findings have the wrong sign: round(100 * type_s(theta = 0.1, se = 0.25), 1)
Show simulation code
type_s <- function(theta, se) {
  p_pos <- 1 - pnorm(1.96 - theta / se) # Pr(est > +1.96 * se)
  p_neg <- pnorm(-1.96 - theta / se) # Pr(est < -1.96 * se)
  p_neg / (p_pos + p_neg)
}

# At theta = 0.1, se = 0.25, ~9% of significant findings have the wrong sign:
round(100 * type_s(theta = 0.1, se = 0.25), 1)

Where next

Back to top