Nothing
## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 6, fig.height = 4)
## ----setup--------------------------------------------------------------------
library(DesignComplexSurvival)
## ----switch-models------------------------------------------------------------
ctl_sw <- ms_model(time = c(0, 4), prog = c(0.10, 0.08), death = 0.01,
switch_prob = 0.3, death_prog = 0.06, switch_rate = 0.04,
death_switch = 0.035, dropout = 0.003)
trt_sw <- ms_model(time = c(0, 4), prog = c(0.06, 0.05), death = 0.008,
death_prog = 0.055, dropout = 0.003)
pr <- ms_prob(ctl_sw, time = c(6, 12, 24))
pr
## ----os-curves, fig.alt = "Overall survival of the control group with and without switching and of the treatment group over 48 months"----
ctl_ns <- ms_model(time = c(0, 4), prog = c(0.10, 0.08), death = 0.01,
death_prog = 0.06, dropout = 0.003)
models <- list(control = ctl_sw, control_no_switch = ctl_ns, treatment = trt_sw)
tt <- seq(0, 48, by = 1)
os <- sapply(models, function(m) ms_surv(m, tt, "os")$surv)
matplot(tt, os, type = "l", lty = 1:3, col = 1, ylim = c(0, 1),
xlab = "Months since randomization", ylab = "Overall survival")
legend("topright", c("Control with switching", "Control without switching",
"Treatment"), lty = 1:3, bty = "n")
median_os <- function(m) {
stats::uniroot(function(t) ms_surv(m, t, "os")$surv - 0.5, c(0.1, 500))$root
}
med <- sapply(models, median_os)
round(med, 1)
## ----switch-power-------------------------------------------------------------
looks <- ms_looks("os", fraction = c(0.6, 1))
pw <- ms_power(ms_scenario(ctl_sw, trt_sw, accrual = ms_accrual(rate = 25)),
n = 500, looks = looks, test = ms_test(), events = 300)
pw_ns <- ms_power(ms_scenario(ctl_ns, trt_sw, accrual = ms_accrual(rate = 25)),
n = 500, looks = looks, test = ms_test(), events = 300)
c(switching = pw$power, no_switching = pw_ns$power)
## ----clocks-------------------------------------------------------------------
m_reset <- ms_model(prog = 0.08, death = 0.01, time_post = c(0, 6),
death_prog = c(0.08, 0.04))
m_fwd <- ms_model(prog = 0.08, death = 0.01, time_post = c(0, 6),
death_prog = c(0.08, 0.04), clock = "forward")
tc <- c(12, 24, 36)
os_clock <- sapply(list(reset = m_reset, forward = m_fwd),
function(m) ms_surv(m, tc, "os")$surv)
rownames(os_clock) <- paste("month", tc)
round(os_clock, 3)
## ----switch-clock-------------------------------------------------------------
m_same <- ms_model(prog = 0.08, death = 0.01, time_post = c(0, 6),
death_prog = c(0.08, 0.06), switch_rate = 0.05,
death_switch = c(0.03, 0.05))
m_since <- ms_model(prog = 0.08, death = 0.01, time_post = c(0, 6),
death_prog = c(0.08, 0.06), switch_rate = 0.05,
death_switch = c(0.03, 0.05), switch_clock = "switch")
os_switch <- sapply(list(same = m_same, since_switch = m_since),
function(m) ms_surv(m, tc, "os")$surv)
rownames(os_switch) <- paste("month", tc)
round(os_switch, 3)
## ----aft-constant-------------------------------------------------------------
m_af1 <- ms_model(prog = 0.08, death = 0.01, death_prog = 0.06,
switch_rate = 0.05, switch_af = 0.7)
m_ph1 <- ms_model(prog = 0.08, death = 0.01, death_prog = 0.06,
switch_rate = 0.05, death_switch = 0.7 * 0.06)
d_af <- max(abs(ms_surv(m_af1, tt, "os")$surv - ms_surv(m_ph1, tt, "os")$surv))
d_af
## ----aft-piecewise------------------------------------------------------------
m_af2 <- ms_model(prog = 0.08, death = 0.01, time_post = c(0, 6),
death_prog = c(0.08, 0.04), switch_rate = 0.05, switch_af = 0.7)
m_ph2 <- ms_model(prog = 0.08, death = 0.01, time_post = c(0, 6),
death_prog = c(0.08, 0.04), switch_rate = 0.05,
death_switch = 0.7 * c(0.08, 0.04))
os_af <- sapply(list(aft = m_af2, hazard_ratio = m_ph2),
function(m) ms_surv(m, tc, "os")$surv)
rownames(os_af) <- paste("month", tc)
round(os_af, 3)
## ----switch-pre---------------------------------------------------------------
ctl_pre <- ms_model(time = c(0, 4), prog = c(0.10, 0.08), death = 0.01,
death_prog = 0.06, death_switch = 0.035, switch_pre = 0.02,
prog_switch = 0.06, death_switch_pre = 0.007, dropout = 0.003)
ms_prob(ctl_pre, time = c(6, 12, 24))
## ----pfs-switch---------------------------------------------------------------
acc <- ms_accrual(rate = 25)
scn_event <- ms_scenario(ctl_pre, trt_sw, accrual = acc)
scn_censor <- ms_scenario(ctl_pre, trt_sw, accrual = acc, pfs_switch = "censor")
ev <- rbind(event = ms_events(scn_event, n = 500, calendar_time = 24, endpoint = "pfs"),
censor = ms_events(scn_censor, n = 500, calendar_time = 24, endpoint = "pfs"))
ev[, c("events_control", "dropouts_control", "events_treatment", "dropouts_treatment")]
pfs_power <- sapply(list(event = scn_event, censor = scn_censor), function(s)
ms_power(s, n = 500, looks = ms_looks("pfs"), test = ms_test(endpoints = "pfs"),
events = 300)$power)
pfs_power
## ----dropout-pfs--------------------------------------------------------------
ctl_dp <- ms_model(time = c(0, 4), prog = c(0.10, 0.08), death = 0.01,
death_prog = 0.06, dropout = 0.003, dropout_pfs = 0.02)
scn_dp <- ms_scenario(ctl_dp, trt_sw, accrual = acc)
rbind(pfs = ms_events(scn_dp, n = 500, calendar_time = 24, endpoint = "pfs"),
os = ms_events(scn_dp, n = 500, calendar_time = 24, endpoint = "os"))[
, c("events_control", "dropouts_control")]
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.