Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.