Skip to content

Instantly share code, notes, and snippets.

Created October 2, 2010 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/607968 to your computer and use it in GitHub Desktop.
Save anonymous/607968 to your computer and use it in GitHub Desktop.
runs <- 1000
nn <- 100
set.seed(2010)
detections <- replicate(n=runs,expr={covariate <- runif(nn)
outcome <- runif(nn)<1/(1+exp(-2*log(2)*covariate+rnorm(nn)))
summary(glm(outcome~covariate,family="binomial"))$coefficients["covariate","Pr(>|z|)"] < .05})
cat("Power:",sum(detections)/runs,"\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment