if (FALSE) {
# Define candidate dose-response models
# (negative sign models decreasing dose-response for hazard)
f_emax <- function(d, ED50) { -d / (ED50 + d) }
f_exponential <- function(d, delta) { -exp(d / delta) + 1 }
f_linear <- function(d) { -d }
f_logistic <- function(d, ED50, delta) {
-1 / (1 + exp((ED50 - d) / delta))
}
f_betamod <- function(d, delta1, delta2, D) {
-dbeta(d / D, delta1 + 1, delta2 + 1)
}
# Log hazard parameters
b0 <- log(log(2) / 0.5) # placebo: median survival 0.5 years
b1 <- log(0.6) + b0 # optimal dose: HR = 0.6 vs. placebo
# Rescale candidate models to match hazard rates
f1 <- function(dose) {
a0 <- f_emax(0, 50); a1 <- f_emax(100, 50)
slope <- (b1 - b0) / (a1 - a0)
intercept <- b0 - slope * a0
intercept + slope * f_emax(dose, 50)
}
f2 <- function(dose) {
a0 <- f_exponential(0, 22.756); a1 <- f_exponential(100, 22.756)
slope <- (b1 - b0) / (a1 - a0)
intercept <- b0 - slope * a0
intercept + slope * f_exponential(dose, 22.756)
}
f3 <- function(dose) {
a0 <- f_emax(0, 6.25); a1 <- f_emax(100, 6.25)
slope <- (b1 - b0) / (a1 - a0)
intercept <- b0 - slope * a0
intercept + slope * f_emax(dose, 6.25)
}
f4 <- function(dose) {
a0 <- f_logistic(0, 40.3287, 6.9764)
a1 <- f_logistic(100, 40.3287, 6.9764)
slope <- (b1 - b0) / (a1 - a0)
intercept <- b0 - slope * a0
intercept + slope * f_logistic(dose, 40.3287, 6.9764)
}
f5 <- function(dose) {
a0 <- f_linear(0); a1 <- f_linear(100)
slope <- (b1 - b0) / (a1 - a0)
intercept <- b0 - slope * a0
intercept + slope * f_linear(dose)
}
f6 <- function(dose) {
a0 <- f_betamod(0, 0.7489, 1.0485, 120)
dstar <- 0.7489 * 120 / (0.7489 + 1.0485)
a1 <- f_betamod(dstar, 0.7489, 1.0485, 120)
slope <- (b1 - b0) / (a1 - a0)
intercept <- b0 - slope * a0
intercept + slope * f_betamod(dose, 0.7489, 1.0485, 120)
}
f <- list(f1, f2, f3, f4, f5, f6)
doselevels <- c(5, 25, 50, 100)
# Run the simulations (each candidate model is the true model in one scenario)
sims <- lapply(1:6, function(i) {
lrsim_mcpmod(
M = 4, alpha = 0.05, accrualIntensity = 360,
lambdas = as.list(exp(f[[i]](c(doselevels, 0)))),
candidateHazardRatios = exp(sapply(f, function(ff) ff(doselevels) - ff(0))),
gammas = list(0, 0, 0, 0, 0),
n = 300, plannedEvents = 242,
maxNumberOfIterations = 1000,
maxNumberOfRawDatasetsPerStage = 10,
seed = 314159,
nthreads = 1
)
})
sapply(sims, function(s) s$overview$overallReject)
}
Run the code above in your browser using DataLab