Skip to content

Instantly share code, notes, and snippets.

@richarddmorey
Created August 30, 2015 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save richarddmorey/db65d83de20fbc06d5ad to your computer and use it in GitHub Desktop.
Save richarddmorey/db65d83de20fbc06d5ad to your computer and use it in GitHub Desktop.
Demonstration that inaccurate original results lead to poor replication coverage (even with no bias)
N1 = 10 # Participants in "original"; inaccurate
N2 = 200 # Participants in "replication"; accurate
M = 100000 # number of simulations
# CI setup
alpha = .05
zstar = qnorm(1-alpha/2)
# Sample means
Xbar1 = rnorm(M, 0, 1/sqrt(N1)) # Original
Xbar2 = rnorm(M, 0, 1/sqrt(N2)) # Replication
# Does the "replication" CI include the "original" mean?
CI.in = (Xbar1 < (Xbar2 + zstar/sqrt(N2))) & (Xbar1 > (Xbar2 - zstar/sqrt(N2)))
# Proportion containing original mean
mean(CI.in)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment