Created
March 29, 2015 16:25
-
-
Save richarddmorey/4f808b875ab370cfd243 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
M = 10000 # Number of sims | |
power = .5 # power | |
## Binomial (fixed N) | |
N1 = rpois(M,2) + 1 ## random choice for N | |
X1 = rbinom(M,N1,power) ## Perform studies | |
mean(X1 / N1) | |
sd(X1 / N1) | |
## Notice above that, as expected, expected prop. | |
## of significant studies is power | |
## Geometric (stop with single nonsig. result) | |
X2 = rgeom(M,1-power) | |
N2 = X2 + 1 | |
# show power | |
sum(X2) / sum(N2) | |
# However, expected proportion sig. is < .5 ! | |
mean(X2 / N2) | |
sd(X2 / N2) | |
## Interestingly, the expected proportion of sig. | |
## studies is *less than* the power! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment