inst/doc/two-endpoints.R

## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")

## ----setup--------------------------------------------------------------------
library(DesignComplexSurvival)

## ----scenario-----------------------------------------------------------------
fl <- ms_scenario(ms_fleischer(median_pfs = 4, median_os = 12),
                  ms_fleischer(median_pfs = 6, median_os = 16),
                  accrual = ms_accrual(rate = 25))
lk2 <- ms_looks(c("pfs", "os"), fraction = c(1, 1),
                test = list(c("pfs", "os"), "os"))
ev2 <- c(pfs = 300, os = 220)

## ----fixed-sequence-----------------------------------------------------------
fs <- ms_power(fl, n = 450, looks = lk2,
               test = ms_test(endpoints = c("pfs", "os"), mtp = "fixed_sequence"),
               events = ev2)
fs

## ----stagewise----------------------------------------------------------------
fs_a <- ms_power(fl, n = 450, looks = lk2,
                 test = ms_test(endpoints = c("pfs", "os"), mtp = "fixed_sequence",
                                hierarchical = "stagewise"),
                 events = ev2)
rbind(overall = fs$power, stagewise = fs_a$power)

## ----bonferroni---------------------------------------------------------------
bf <- ms_power(fl, n = 450, looks = lk2,
               test = ms_test(endpoints = c("pfs", "os"), mtp = "bonferroni",
                              weights = c(0.8, 0.2)),
               events = ev2)
rc <- ms_power(fl, n = 450, looks = lk2,
               test = ms_test(endpoints = c("pfs", "os"), mtp = "bonferroni",
                              weights = c(0.8, 0.2), transition = c(1, 1)),
               events = ev2)
rbind(fixed_sequence = fs$power, bonferroni = bf$power, recycling = rc$power)
rc$looks[, c("endpoint", "look", "time", "z_upper", "z_upper_recycled",
             "p_upper", "p_upper_recycled")]

## ----fwer---------------------------------------------------------------------
os_null <- ms_scenario(ms_fleischer(median_pfs = 4, median_os = 12),
                       ms_fleischer(median_pfs = 6, median_os = 12),
                       accrual = ms_accrual(rate = 25))
fw <- ms_power(fl, n = 450, looks = lk2,
               test = ms_test(endpoints = c("pfs", "os"), mtp = "fixed_sequence"),
               events = ev2, null_scenarios = list(os = os_null))
fw$fwer

## ----interim------------------------------------------------------------------
lk3 <- ms_looks(c("pfs", "pfs", "os"), fraction = c(0.6, 1, 1),
                test = list("pfs", c("pfs", "os"), "os"))
fs3 <- ms_power(fl, n = 450, looks = lk3,
                test = ms_test(endpoints = c("pfs", "os"), mtp = "fixed_sequence"),
                events = ev2)
fs3$looks[, c("endpoint", "look", "trigger", "time", "events", "z_upper",
              "prob_upper")]
rbind(two_analyses = fs$power, three_analyses = fs3$power)

## ----correlation--------------------------------------------------------------
cv <- lr_cov(fl, n = 450, calendar_time = 24, endpoint = c("pfs", "os"),
             variance = "studentized")
cv0 <- lr_cov(ms_null(fl), n = 450, calendar_time = 24, endpoint = c("pfs", "os"))
c(design = stats::cov2cor(cv$sigma)[1, 2], global_null = stats::cov2cor(cv0$sigma)[1, 2])

Try the DesignComplexSurvival package in your browser

Any scripts or data that you put into this service are public.

DesignComplexSurvival documentation built on Nov. 23, 2026, 5:07 p.m.