-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_simu.R
61 lines (49 loc) · 1.63 KB
/
demo_simu.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
setwd("/home/r6user2/Documents/TQ/ABC")
library(parallel)
source("utilities.R")
source("ABC_utils.R")
target <- 0.20
ncohort <- 12
cohortsize <- 3
init.level <- 1
nsimu <- 100
seeds <- 1:nsimu
add.args <- list(alp.prior=0.5, bet.prior=0.5, J=2e4, delta=0.10, cutoff.eli=0.95, cutoff.num=3)
p.true <- c(0.05, 0.06, 0.08, 0.11, 0.19, 0.34)
tmtd <- MTD.level(target, p.true)
print(p.true)
ndose <- length(p.true)
set.seed(1)
ps.name <- paste0("./pssprior-ndose-", ndose, "-phi-", 100*target, "-J-", add.args$J, "-delta-", 100*add.args$delta, ".RData")
if (file.exists(ps.name)){
load(ps.name)
}else{
pss.prior <- gen.prior(ndose, phi=target, J=add.args$J, delta=add.args$delta)
save(pss.prior, file=ps.name)
}
run.fn <- function(i){
print(i)
set.seed(seeds[i])
ABC.res <- ABC.simu.fn(target, p.true, ncohort=ncohort, cohortsize=cohortsize, init.level=init.level, add.args=add.args)
ress <- list(
ABC = ABC.res,
paras=list(p.true=p.true,
mtd=tmtd,
add.args=add.args,
target=target,
ncohort=ncohort,
cohortsize=cohortsize)
)
ress
}
ncores <- 50
m.names <- c("ABC")
results <- mclapply(1:nsimu, run.fn, mc.cores=ncores)
file.name <- paste0("./results/", "SimuABC", "_", nsimu, "_ncohort_", ncohort, ".RData")
save(results, file=file.name)
sum.all <- list()
for (m.name in m.names){
sum.all[[m.name]] <- phase1.post.fn(lapply(1:nsimu, function(i)results[[i]][[m.name]]))
}
print(tmtd)
print(phase.I.pretty.tb(sum.all))