21 lines
1.1 KiB
R
21 lines
1.1 KiB
R
# RCT ITT truths for every world x scenario (the landmark and naive own estimands are
|
|
# estimated within replicates by run_oracle()). Writes simulations/truths/truths_rct.csv.
|
|
# Usage: Rscript simulations/03_limits.R [n] [cores]
|
|
pkgload::load_all("pvisim", quiet = TRUE)
|
|
suppressPackageStartupMessages(library(data.table))
|
|
a <- commandArgs(TRUE)
|
|
n <- if (length(a) >= 1) as.numeric(a[1]) else 5e5
|
|
cores <- if (length(a) >= 2) as.integer(a[2]) else 6L
|
|
raw <- yaml::read_yaml(default_params_path())
|
|
jobs <- CJ(world = names(raw$worlds), scenario = names(raw$scenarios), sorted = FALSE)
|
|
res <- parallel::mclapply(seq_len(nrow(jobs)), function(i) {
|
|
w <- jobs$world[i]; s <- jobs$scenario[i]
|
|
par <- load_params(w, s)
|
|
rbind(rct_truth(par, "realistic", n = 1e6)[outcome %in% c("limb", "male", "disease", "rr", "nco1", "nco2")],
|
|
rct_truth(par, "ideal", n = 1e6)[outcome %in% c("limb", "male", "disease", "rr", "nco1", "nco2")])
|
|
}, mc.cores = cores)
|
|
bad <- vapply(res, inherits, TRUE, "try-error")
|
|
if (any(bad)) stop(res[bad][[1]])
|
|
fwrite(rbindlist(res), "simulations/truths/truths_rct.csv")
|
|
cat("wrote simulations/truths/truths_rct.csv\n")
|