This file contains hidden or 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
# script for initial trial simulation | |
# plots relationship between trial endpoints and power for entry into network model | |
# function to compute Z from endpoints and sample sizes | |
get_Z = function(numerator,denominator){ # each input is a vector length 2 | |
phat = (numerator)/denominator | |
sigma = phat*(1-phat) / denominator |
This file contains hidden or 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
## computes test statistic for a single trial | |
compute_test_statistic <- function(sample_size,cases,eta=0.7){ | |
# assume fixed and equal allocation | |
n0 <- round(sample_size/2) | |
n1 <- sample_size - n0 | |
# get relative risk from vaccine efficacy eta | |
relative_risk <- 1 - eta | |
# sample number of fails for control | |
f0 <- rbinom(max(length(cases),length(sample_size)),cases,1 / (1+relative_risk)) | |
# get number of fails for experimental |