Speed-ups (shared PVI fit, clones once, case-control sampled deferred model); final scale 200 reps extending the draft (D51)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -10,7 +10,7 @@ cores <- as.integer(opt("--cores", "10"))
|
||||
cfg <- yaml::read_yaml("simulations/config/experiments.yml")
|
||||
g <- cfg[[grid_name]]; sc <- cfg$scales[[scale]]
|
||||
worlds <- if (is.null(opt("--worlds", NULL))) g$worlds else strsplit(opt("--worlds", NULL), ",")[[1]]
|
||||
outdir <- file.path("results", grid_name, scale)
|
||||
outdir <- file.path("results", grid_name, if (is.null(sc$dir)) scale else sc$dir)
|
||||
jobs <- CJ(world = worlds, scenario = unlist(g$scenarios), rep = seq_len(sc$reps), sorted = FALSE)
|
||||
jobs[, file := file.path(outdir, world, scenario, sprintf("rep%03d.csv", rep))]
|
||||
todo <- jobs[!file.exists(file)]
|
||||
@@ -21,25 +21,17 @@ one_job <- function(i) {
|
||||
par <- load_params(j$world, j$scenario)
|
||||
rec <- simulate_records(par, rep = j$rep, n = sc$n_patients)
|
||||
out <- list()
|
||||
with_v2 <- function(r) if (r$variant[1] == "V1_ignore") # same fit, two SEs
|
||||
rbind(r, copy(r)[, `:=`(variant = "V2_cluster", se = se_cluster)]) else r
|
||||
nce_out <- c(male = "t_male", disease = "t_disease")
|
||||
for (v in g$variants) {
|
||||
for (d in g$designs) {
|
||||
r <- run_design(rec, d, v)
|
||||
if (v == "V1_ignore") { # same fit, two SEs
|
||||
r2 <- copy(r)[, `:=`(variant = "V2_cluster", se = se_cluster)]
|
||||
r <- rbind(r, r2)
|
||||
}
|
||||
out[[length(out) + 1]] <- r[, analysis := "main"]
|
||||
}
|
||||
if (isTRUE(g$nce)) for (d in c("landmark", "ccw")) {
|
||||
r <- run_design(nce_records(rec), d, v, outcomes = c(male = "t_male", disease = "t_disease"))
|
||||
if (v == "V1_ignore") r <- rbind(r, copy(r)[, `:=`(variant = "V2_cluster", se = se_cluster)])
|
||||
out[[length(out) + 1]] <- r[, analysis := "nce"]
|
||||
}
|
||||
}
|
||||
for (d in c("landmark", "ccw")) { # unadjusted NCE (supplement, D36), V1/V2 only
|
||||
r <- run_design(nce_records(rec, adjust_pvi = FALSE), d, "V1_ignore", outcomes = c(male = "t_male", disease = "t_disease"))
|
||||
out[[length(out) + 1]] <- r[, analysis := "nce_unadjusted"]
|
||||
out[[length(out) + 1]] <- with_v2(run_designs(rec, unlist(g$designs), v))[, analysis := "main"]
|
||||
if (isTRUE(g$nce))
|
||||
out[[length(out) + 1]] <- with_v2(run_designs(nce_records(rec), c("landmark", "ccw"), v, nce_out))[, analysis := "nce"]
|
||||
}
|
||||
# unadjusted NCE (supplement, D36), V1/V2 only
|
||||
out[[length(out) + 1]] <- with_v2(run_designs(nce_records(rec, adjust_pvi = FALSE), c("landmark", "ccw"),
|
||||
"V1_ignore", nce_out))[, analysis := "nce_unadjusted"]
|
||||
out[[length(out) + 1]] <- run_oracle(rec)[, analysis := "main"] # own estimand of landmark / naive
|
||||
for (dz in g$rct) {
|
||||
r <- run_rct(par, dz, rep = j$rep)
|
||||
|
||||
Reference in New Issue
Block a user