## The results presented in the mansucript were obtained using: ## R version 3.6.3 (2020-02-29) ## Platform: x86_64-apple-darwin15.6.0 (64-bit) ## Running under: macOS Catalina 10.15.4 ## Matrix products: default ## BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib ## LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib ## locale: ## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## other attached packages: ## [1] idem_4.0 Rcpp_1.0.3 ## loaded via a namespace (and not attached): ## [1] compiler_3.6.3 pillar_1.4.3 prettyunits_1.1.1 ## [4] tools_3.6.3 digest_0.6.25 bit_1.1-15.2 ## [7] pkgbuild_1.0.6 memoise_1.1.0 RSQLite_2.2.0 ## [10] lifecycle_0.1.0 tibble_2.1.3 gtable_0.3.0 ## [13] lattice_0.20-38 pkgconfig_2.0.3 rlang_0.4.5 ## [16] Matrix_1.2-18 DBI_1.1.0 cli_2.0.2 ## [19] parallel_3.6.3 proto_1.0.0 loo_2.2.0 ## [22] gridExtra_2.3 dplyr_0.8.4 vctrs_0.2.3 ## [25] bit64_0.9-7 stats4_3.6.3 grid_3.6.3 ## [28] tidyselect_1.0.0 glue_1.3.1 inline_0.3.15 ## [31] sqldf_0.4-11 R6_2.4.1 processx_3.4.2 ## [34] fansi_0.4.1 survival_3.1-8 gsubfn_0.7 ## [37] rstan_2.19.3 blob_1.2.1 ggplot2_3.2.1 ## [40] callr_3.4.2 purrr_0.3.3 magrittr_1.5 ## [43] codetools_0.2-16 scales_1.1.0 ps_1.3.2 ## [46] StanHeaders_2.21.0-1 matrixStats_0.55.0 splines_3.6.3 ## [49] assertthat_0.2.1 colorspace_1.4-1 lazyeval_0.2.2 ## [52] munsell_0.5.0 chron_2.3-55 crayon_1.3.4 library("idem") sessionInfo() options(digits = 3) set.seed(100) head(abc) ## ----------- section 3.2: data preparation -------------- try(err.data <- imData(abc, trt = "TRT", outcome = c("Y1", "Y2"), y0 = NULL, endfml = "Y2", bounds = c(10, 20), duration = 365)) err.data <- imData(abc, trt = "TRT", outcome = c("Y1", "Y2"), y0 = NULL, endfml = "Y2", bounds = c(10, 20), duration = 365, err.terminate = FALSE) err.data im.abc <- imData(abc, trt = "TRT", surv = "SURV", outcome = c("Y1", "Y2"), unitTime = "days", trt.label = c("UC+SBT", "SAT+SBT"), cov = "AGE", endfml = "Y2", duration = 365, bounds = c(0, 100)) im.abc summary(im.abc) pdf("idem_survivor.pdf", height = 6, width = 12) plot(im.abc, opt = "survivor") dev.off() pdf("idem_pattern.pdf", height = 6, width = 12) plot(im.abc, opt = "missing", cols = c("blue", "gray"), order.by = "pattern") dev.off() pdf("idem_surv.pdf", height = 6, width = 6) plot(im.abc, opt = "KM") dev.off() summary(im.abc, opt = "missid") ## ----------- section 3.3: imputation -------------- rst.fit <- imFitModel(im.abc) rst.fit pdf("idem_fit.pdf", height = 6, width = 8) plot(rst.fit, mfrow = c(2, 4)) dev.off() rst.mixing <- imImpSingle(abc[1, ], rst.fit, normal = FALSE, chains = 4, iter = 1000, warmup = 500, seed = 10000, refresh = 0) rst.mixing pdf("idem_trace.pdf", height = 6, width = 12) plot(rst.mixing) dev.off() rst.imp <- imImpAll(rst.fit, deltas = seq(-0.2, 0.2, 0.05), n.imp = 5, normal = FALSE, chains = 4, iter = 1000, warmup = 500, seed = 10000, refresh = 0) rst.imp pdf("idem_imp.pdf", height = 6, width = 12) plot(rst.imp, opt = "imputed", deltas = c(-0.2, 0, 0.2), xlim = c(0, 100), ylim = c(0, 0.06), endp = TRUE) dev.off() pdf("idem_composite.pdf", height = 6, width = 8) plot(rst.imp, opt = "composite", delta = 0) dev.off() ## ----------- section 3.4: inference -------------- rst.est <- imInfer(rst.imp, n.boot = 0, effect.quantiles = c(0.25, 0.5, 0.75)) print(rst.est, delta0 = c(-0.2, 0, 0.2), delta1 = c(-0.2, 0, 0.2)) rst.final <- imInfer(rst.imp, n.boot = 100, n.cores = 5, quant.ci = c(0.025, 0.975), seed = 10000) save(rst.final, file = "paper_idem.Rdata") print(rst.final, delta0 = c(-0.2, 0, 0.2), delta1 = c(-0.2, 0, 0.2)) pdf("idem_contour.pdf", height = 8, width = 8) plot(rst.final, nlevels = 30, con.v = 0.05, main = "P-Value") dev.off() pdf("idem_contour_2.pdf", height = 8, width = 8) plot(rst.final, opt = "effect", nlevels = 30, con.v = c(-0.1, -0.2, -0.3), main=expression(theta)) dev.off() rst.survonly <- summary(rst.final, opt = "survivor") rst.survonly pdf("idem_contour_surv.pdf", height = 8, width = 8) plot(rst.survonly, nlevels = 30, con.v = 0.05, main = "Survivors Only: P-Value") dev.off() pdf("idem_contour_surv_2.pdf", height = 8, width = 8) plot(rst.survonly, opt = "effect", nlevels = 30, con.v = c(-15, 0, 15), main = expression(theta[surv])) dev.off() rst.sace <- summary(rst.final, opt = "SACE", sace.deltas = seq(-2, 0, by = 0.5)) rst.sace pdf("idem_sace_2.pdf", height = 8, width = 8) plot(rst.sace, by.sace = FALSE, sace.delta = -1, main = "SACE: P-Value") dev.off() pdf("idem_sace.pdf", height = 8, width = 8) plot(rst.sace, by.sace = TRUE, delta0 = 0, delta1 = 0, main = expression(theta[SACE])) dev.off()