/
MK_PhenomSim.R
104 lines (97 loc) · 4.25 KB
/
MK_PhenomSim.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
####################################################################################################
## Set up R CMD BATCH scripts for running on HPC cluster: Phenomenological hazard model with varying
## degrees of variation in the weekly decay rate and varying degrees of fluctuation around a smooth
## trend
####################################################################################################
## Code base accompanying:
##
## Bellan, SE, JRC Pulliam, CAB Pearson, DChampredon, SJ Fox, L Skrip, AP Galvani, M Gambhir, BA
## Lopman, TC Porco, LA Meyers, J Dushoff (2015). The statistical power and validity of Ebola
## vaccine trials in Sierra Leone: A simulation study of trial design and analysis. _Lancet
## Infectious Diseases_.
##
## Steve Bellan, March 2015
## License at bottom.
####################################################################################################
sapply(c('simFuns.R','AnalysisFuns.R','CoxFxns.R','EndTrialFuns.R'), source)
batchdirnm <- file.path('BigResults','FalsePosFluct')
routdirnm <- file.path(batchdirnm,'Routs')
if(!file.exists(batchdirnm)) dir.create(batchdirnm)
if(!file.exists(routdirnm)) dir.create(routdirnm)
tnms <- c('SWCT','RCT','FRCT')
numEach <- 12*10
p2 <- simTrial(makeParms('RCT',small=F, ord='none', delayUnit = 0, clusSize=300, hazType = 'Phenom', weeklyDecay = .9, cvWeeklyDecay = .5, cvClus = 1.5, cvClusTime = 0.5, numClus = 20))
pits <- c(.075)
parmsMat <- as.data.table(expand.grid(
seed = 1:numEach
, trial = tnms
, hazType = 'Phenom'
, weeklyDecay = .9
, cvWeeklyDecay = c(0, .5, 1)
, cvClusTime = c(0, .25, .5, 1)
, cvClus = 1.8
, ord = c('none','TU')
, propInTrial = pits
, sdLogIndiv = makeParms()$sdLogIndiv
, delayUnit = 7
, immunoDelay = 21
, vaccEff = 0
))
parmsMat <- parmsMat[!(trial=='SWCT' & (delayUnit==0 | ord=='TU'))] ## SWCT must have delay and cannot be ordered
parmsMat <- parmsMat[!(delayUnit==0 & ord=='TU')] ## ordering is meaningless with simultaneous instant vacc
parmsMat <- parmsMat[ !(delayUnit==0 & trial=='FRCT')] ## FRCT = RCT when delayUnit=0
parmsMat$simNum <- 1:nrow(parmsMat)
parmsMat$batchdirnm <- batchdirnm
nmtmp <- 'simFP-pit75-'
parmsMat$saveNm <- nmtmp
parmsMat$nsims <- 17 ## 17*12 is ~ 2000 simulations each (2040 but we'll round)
parmsMat$reordLag <- 14
parmsMat$nboot <- 200
parmsMat$trialStartDate <- '2015-02-18'
nrow(parmsMat)
addParm <- function(x, parmsMat,ii) {
for(pp in 1:length(parmsMat)) {
tempP <- as.data.frame(parmsMat)[,pp]
isch <- !is.numeric(tempP[1])
parmAdd <- tempP[parmsMat$simNum==ii]
addStrg <- paste0(" ", names(parmsMat)[pp], "=", "\""[isch], parmAdd, "\""[isch])
x <- paste0(x, addStrg)
}
return(x)
}
parmsMat[, length(nboot), propInTrial]
parmsMat[, length(nboot), vaccEff]
parmsMat[, length(nboot), list(trial,ord)]
parmsMat[, length(nboot), list(trial,cvClusTime,ord)]
jbs <- NULL
immDs <- parmsMat[,unique(immunoDelay)]
jn <- 0
for(dd in 1:length(tnms)) {
parmsMatDo <- parmsMat[trial==tnms[dd]]
jn <- jn+1
jbs <- rbind(jbs, data.table(jn=jn, trial=tnms[dd]))
sink(paste0('FalsePosSim',jn,'.txt'))
for(ii in parmsMatDo$simNum) {
cmd <- "R CMD BATCH '--no-restore --no-save --args"
cmd <- addParm(cmd, parmsMatDo, ii)
cmd <- paste0(cmd, " ' startSim.R ", file.path(batchdirnm,'Routs', paste0(nmtmp, sprintf("%06d", ii),'.Rout')),
sep='')
cat(cmd) # add command
cat('\n') # add new line
}
sink()
}
jbs
####################################################################################################
### LICENSE
###
### This code is made available under a Creative Commons Attribution 4.0
### International License. You are free to reuse this code provided that you
### give appropriate credit, provide a link to the license, and indicate if
### changes were made.
### You may do so in any reasonable manner, but not in any way that suggests
### the licensor endorses you or your use. Giving appropriate credit includes
### citation of the above publication *and* providing a link to this repository:
###
### https://github.com/sbellan61/EbolaVaccPowerSL
####################################################################################################