Designing complex time-to-event trials without simulation

knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 6, fig.height = 4.5)
library(DesignComplexSurvival)

DesignComplexSurvival computes the operating characteristics of two-group time-to-event trials analyzed with the log-rank test, without patient-level simulation. This article first describes what the package computes and which trial settings it covers, and then goes through a design with a single endpoint. The other articles are listed at the end.

What the package computes

The analyses can be driven by the events of progression-free survival (PFS) or overall survival (OS), take place at calendar times, or mix the two. The computations use closed forms, numerical integration and multivariate normal probabilities, so that they are fast and give the same result every time; they rest on the normal approximation of the log-rank statistics.

The model of each group

Each group follows a multistate model with five states:

```{=html}

switch at progression (prog, switch_prob) prog switch_rate death death_prog death_switch switch_pre death_switch_pre progression after a switch (prog_switch) 1 Progression-free 2 Progressed (no switch) 3 Switched 5 Progression-free after a switch 4 Dead
The states of the model of one group and the arguments of ms_model() that give the transitions between them. State 5 is used only when switch_pre is positive.

PFS is the time to leave the progression-free states 1 and 5, and OS is the
time to enter state 4. Since both come from the same course of each patient,
the dependence between them is part of the model and needs no separate
assumption. A switch (also called treatment switching or crossover) is a move
to the experimental treatment or to another treatment; it can be specified in
either group:

* at progression, with probability `switch_prob`, or after progression, with
  hazard `switch_rate`;
* before progression, with hazard `switch_pre`; PFS is then followed up to
  progression or death, or censored at the switch (`pfs_switch` in
  `ms_scenario()`);
* from a calendar time on, for example after an interim analysis
  (`switch_start` in `ms_scenario()`).

All intensities are piecewise constant, and the number of intervals is not
limited, so that a delayed or diminishing treatment effect is given through
the intervals. Before progression the intensities are functions of the time
since randomization. After progression they are functions of the time since
progression (`clock = "reset"`) or since randomization (`"forward"`). The
death hazard after a switch can be measured on the same clock or from the
switch (`switch_clock = "switch"`), or the switch can have an accelerated
failure time effect (`switch_af`). Dropout is piecewise exponential by group,
the same in all states, and `dropout_pfs` adds a censoring of PFS only.

## What can be specified

| Feature | Options | Status |
|---|---|---|
| Accrual | piecewise uniform, by rates or by proportions and a duration | supported |
| Allocation | any ratio, for example 2:1 | supported |
| Dropout | piecewise exponential by group; a censoring of PFS only | supported |
| Hazards | piecewise constant, with delayed or diminishing effects through the intervals | supported |
| Switching at and after progression | probability at progression, hazard after progression, death hazard after the switch | supported |
| Effect of a switch | death hazard on the post-progression clock or from the switch, or an accelerated failure time effect | supported |
| Switching before progression | PFS followed up or censored at the switch | supported |
| Switching from a calendar time | OS tested alone | partly |
| Timing of the analyses | events of OS or PFS, calendar times, or a mix; final analysis at a given follow-up after the end of accrual | supported |
| Efficacy bounds | alpha spending: O'Brien-Fleming and Pocock types, Hwang-Shih-DeCani, power family, user-defined | supported |
| Futility bounds | fixed (Z or hazard ratio scale) or beta spending; binding or non-binding | supported |
| Two endpoints | PFS and OS by fixed sequence (two procedures) or Bonferroni, with recycling of the level after a rejection | supported |
| Familywise error rate | under the global null hypothesis and under partial null scenarios given by the user | supported |
| Solving for | number of events, sample size, accrual duration or follow-up | supported |
| Expected values | study duration, events and enrolled patients when the trial stops at the bounds, under the design and null scenarios (one endpoint) | supported |
| Conditional power | at an interim analysis, under the design scenario, the null hypothesis, the current trend, a hazard ratio or another scenario (one endpoint) | supported |
| Approximations | mean of the statistic (two choices) and covariance (three choices) | supported |
| Smooth hazards (Weibull), cure fractions, delays that vary between patients | piecewise constant approximation of the hazard of each group (one endpoint) | approximate |
| Not covered | weighted log-rank tests, restricted mean survival time, stratification, non-inferiority and equivalence, a fixed follow-up for each patient, repeated switches back and forth, dropout that depends on the state, switching started by interim results, more than two groups | not supported |

PFS and OS can be tested together with switching and with group sequential
designs; the exception is switching from a calendar time, which covers the OS
statistic alone. The other articles describe each part in detail.

## Building a design

A design is built in four steps:

1. the scenario: the models of the two groups (`ms_model()`, or
   `ms_fleischer()` for exponential progression-free survival (PFS) and
   overall survival (OS)), the allocation and the accrual (`ms_accrual()`,
   `ms_scenario()`);
2. the timing of the analyses (`ms_looks()`);
3. the test: the endpoints, the spending functions, the futility bounds and
   the approximations of the distribution of the statistics (`ms_test()`);
4. the evaluation: the power and type I error of a given design
   (`ms_power()`), or the number of events, sample size, accrual duration or
   follow-up for a target power (`ms_size()`).

The following example goes through the four steps for a single endpoint with
a delayed treatment effect.

## A delayed treatment effect

The control group has exponential survival with a median of 12 months. In
the treatment group the hazard ratio is 1 for the first 6 months and 0.65
afterwards. Patients are enrolled at 10 per month for 3 months and at 30 per
month afterwards, and the dropout hazard is 0.003 per month in both groups.

```r
lam <- log(2) / 12
ctl <- ms_model(death = lam, dropout = 0.003)
trt <- ms_model(time = c(0, 6), death = c(lam, 0.65 * lam), dropout = 0.003)
acc <- ms_accrual(time = c(0, 3), rate = c(10, 30))
scn <- ms_scenario(ctl, trt, allocation = 1, accrual = acc)
ev <- ms_events(scn, n = 700, calendar_time = c(12, 24, 36))
ev[, c("time", "enrolled", "events_control", "events_treatment", "events")]

With 700 patients, r round(ev$events[3]) events are expected by month 36.

The design has interim analyses at 50 and 75 percent of the events, an efficacy bound of O'Brien-Fleming type and a non-binding futility bound by beta spending. ms_size() finds the number of events for a power of 90 percent.

looks <- ms_looks("os", fraction = c(0.5, 0.75, 1))
test <- ms_test(futility = "beta", sf_fut = "HSD", param_fut = -2)
des <- ms_size(scn, looks = looks, test = test, power = 0.9,
               solve_for = "events", n = 700)
des

The accrual ends at month r round(des$accrual_duration, 1). The final analysis needs r des$events events and takes place at month r round(des$study_duration, 1). The type I error is r signif(des$type1[["nonbinding"]], 3) when the futility bounds are ignored.

plot() with type = "survival" draws the survival functions of the two groups of the scenario up to the final analysis; PFS is drawn in addition to OS when the model of a group has progression:

plot(des, type = "survival")

The mean of the standardized statistic can be computed directly from the hazards (the default, following Yung and Liu 2020) or with the approximation of Schoenfeld (1981), which uses the event-weighted average of the log hazard ratio.

t_fin <- des$study_duration
rbind(direct = lr_moments(scn, 700, t_fin)$z_mean,
      schoenfeld = lr_moments(scn, 700, t_fin, mean = "schoenfeld")$z_mean)

Summaries of a design

summary() gives an overview of the design, and as.data.frame() the table of the looks:

summary(des)
as.data.frame(des)[, c("time", "events", "z_upper", "hr_upper", "z_lower",
                       "cum_power")]

The summary also gives the expected study duration, events and enrolled patients when the trial stops at the bounds, under the design scenario and under the null scenario. plot(des) draws the bounds, and ms_cond_power() gives the conditional power at an interim analysis; both are described in vignette("group-sequential").

ms_power() evaluates a design with a given final number of events, a given follow-up after the end of accrual, or analyses at calendar times. With the same looks and test and the final analysis 12 months after the end of accrual:

pw12 <- ms_power(scn, n = 700, looks = looks, test = test, followup = 12)
c(power = pw12$power, final_analysis = pw12$study_duration,
  events = pw12$events)

The final analysis then takes place at month r round(pw12$study_duration, 1) with r round(pw12$events) expected events, and the power is r round(pw12$power, 3).

Further articles

References

Schoenfeld D (1981). The asymptotic properties of nonparametric tests for comparing survival distributions. Biometrika 68:316-319.

Yung G, Liu Y (2020). Sample size and power for the weighted log-rank test and Kaplan-Meier based tests with allowance for nonproportional hazards. Biometrics 76:939-950.



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.