Skip to content

Instantly share code, notes, and snippets.

@johnjosephhorton
Created December 9, 2015 10:54
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 johnjosephhorton/b93cbcd1e94a2f03bbb7 to your computer and use it in GitHub Desktop.
Save johnjosephhorton/b93cbcd1e94a2f03bbb7 to your computer and use it in GitHub Desktop.
SimExperiment <- function(num.groups, sample.size, beta, randomize.by.group = FALSE){
"Simulate running an analysis of the experiment with linear regression"
df <- CreateClusteredData(num.groups, sample.size, beta, randomize.by.group = randomize.by.group)
m <- lm(y ~ trt, data = df)
c(as.numeric(coef(m)[2]), as.numeric(sqrt(diag(vcov(m))[2])))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment