Created
February 13, 2015 21:21
-
-
Save davharris/99652949393224803709 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = 10 | |
delta = 0.1 | |
sd = 1 | |
# Calculate power with n and delta | |
power.t.test(n = n, delta = delta, sd = 1, type = "one.sample") # ~5% power | |
# Run 10,000 t.tests | |
p = replicate(1E4, t.test(rnorm(n, mean = delta, sd = 1))$p.value) | |
mean(p < .025 | p > .975) # reject ~5.2% of the time |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment