Files
tte-surgery/simulations/explore_scenarios.R
T
chendun1995andClaude Opus 5.5 fc1461d5b5 Truths, estimators (naive, landmark, CCW, sequential; physician variants V1-V4) and simulated RCTs
- truths.R: interventional truths by common random numbers (A, B1, B2, sequential ITT)
- estimators.R: weighted Aalen-Johansen with influence-function SEs (patient / physician cluster)
- rct.R: realistic and ideal trials, ITT and as-treated; RCT ITT truths
- scenario effects tuned in W0: harm +5.1 pp, benefit-then-harm -1.2 pp at 24 mo, +3.1 at 60

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 09:01:13 -04:00

18 lines
1.1 KiB
R

# Explore effect sizes: RD(A - B1) by month for MALE and the disease composite in W0.
pkgload::load_all("pvisim", quiet = TRUE)
suppressMessages(library(data.table))
args <- commandArgs(TRUE)
grid <- if (length(args)) eval(parse(text = args[1])) else
list(c(0, 0), c(0.3, 0.03), c(1.2, 0.04))
par0 <- load_params("W0", "null")
pop <- make_population(par0, n = 2e5, seed = 9L)
ci <- function(t, h) mean(!is.na(t) & t < h)
for (g in grid) {
par <- load_params("W0", "null", overrides = list(effect = list(relief = g[1], kappa = g[2])))
ev <- lapply(c("A", "B1"), function(p) simulate_course(pop, par, policy(p), seed = 10L, record = FALSE)$events)
rd <- function(col, h) 100 * (ci(ev[[1]][[col]], h) - ci(ev[[2]][[col]], h))
cat(sprintf("relief %.2f kappa %.3f | disease RD @12 %+.1f @24 %+.1f @60 %+.1f | MALE RD @60 %+.1f (A %.1f%% B1 %.1f%%) | death RD %+.2f\n",
g[1], g[2], rd("t_disease", 12), rd("t_disease", 24), rd("t_disease", 60), rd("t_male", 60),
100 * ci(ev[[1]]$t_male, 60), 100 * ci(ev[[2]]$t_male, 60), rd("t_death", 60)))
}