Try it in R: The Statistical Significance Filter
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
- Shrink the true effect. Before editing, predict: if you cut
thetafrom0.2to0.05(keepingse <- 0.25), will the average significant estimateavg_sigdrop toward0.05? Changetheta <- 0.05on line 2 and click Run Code. Notice thatavg_sigstays stuck above0.50—because the significance threshold1.96 * se = 0.49sets a hard floor on what can be called “significant”, inflating the exaggeration ratio past \(10\times\). - 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? - Shrink the noise instead. Keep
theta <- 0.2and lowersefrom0.25to0.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 near1.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
- Read the full entry: The Statistical Significance Filter.
- Continue to Lab 2: Try it in R: 16, where the same noise arithmetic explains why subgroup and interaction claims need 16 times the sample size.