Nothing
############# Experiments SURVIVAL
#----
# 0) Setup
#----
source("../def.R")
NLIST <- 131L
### censoring prob = .3, .7
BETACENSLIST <- qlogis(1 - c(.3, .7))
PROBNAM <- "survival"
source("../../helpers.R")
set.seed(SEED)
setups <- expand.grid(repl = seq(1, REPL), N = NLIST, P = PLIST,
truetau = TAULIST, lambda = LAMBDALIST, betacens = BETACENSLIST)
setups$seed <- round(runif(nrow(setups)) * 1e8)
#----
# 1) Load helper functions & libraries
#----
pkgs <- c("tram", "batchtools", "multcomp", "survival", "RobinCar", "speff2trial")
get_packages(pkgs)
generate_data <- function(...) generate_surv(..., RCT = TRUE)
fun <- function(job, N, P, truetau, lambda, betacens, seed, ...) {
d <- generate_data(N = N, P = P, parm = c(truetau = truetau, lambda = lambda, betacens = betacens), seed = seed)
return(d)
}
#----
# 2) Define extra methods
#----
fun_covhr <- function(instance, ...) {
instance$time <- instance$y[,1]
instance$cens <- instance$y[,2]
instance$w01 <- (0:1)[instance$w]
xnnames <- names(instance)[grep("x", names(instance))]
m <- robincar_covhr(instance[, c("time", "cens", "w01", xnnames)],
treat = "w01", response = "time", event = "cens",
covariate = xnnames)
tau <- m$result$theta_CL
setau <- m$result$se_theta_CL
list(tau = tau, se = setau, wald = tau + qnorm(c(.025, .975)) * setau,
pvalue = 2 * pnorm(abs(tau / setau), lower = FALSE))
}
fun_speffSurv <- function(instance, fixed = FALSE, ...) {
xnnames <- names(instance)[grep("x", names(instance))]
fm <- as.formula(paste("y ~", paste(xnnames, collapse = "+")))
instance$w01 <- (0:1)[instance$w]
m <- speffSurv(fm, data = instance, trt.id = "w01", fixed = fixed || (length(xnnames) == 1))
tau <- m$beta["Speff"]
setau <- sqrt(m$varbeta)["Speff"]
if (!fixed) {
selvars <- unique(do.call("c", sapply(m$formula, function(x) list(all.vars(x[-2])))))
} else {
selvars <- c("x", xnnames)
}
list(tau = tau, se = setau, wald = tau + qnorm(c(.025, .975)) * setau,
pvalue = 2 * pnorm(abs(tau / setau), lower = FALSE), selvars = selvars)
}
methods <- list("coxph_w" = fun_coxph_w,
"coxph_wx" = fun_coxph_wx,
"mmlt_coxph" = fun_mmlt_coxph,
"logrankCL" = fun_covhr,
"speffSurv" = fun_speffSurv)
if (TESTONLY) {
d <- fun(1, 100, 5, truetau = 0.5, lambda = 0.5, betacens = qlogis(.5), seed = 1)
print(mean(d$y[,2]))
print(lapply(methods, function(f) f(d)))
} else {
source("../../run_experiments.R")
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.