Skip to content

Instantly share code, notes, and snippets.

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