Learn R Programming

gsDesign2

Objective

The goal of gsDesign2 is to enable fixed or group sequential design under non-proportional hazards. Piecewise constant enrollment, failure rates and dropout rates for a stratified population are available to enable highly flexible enrollment, time-to-event and time-to-dropout assumptions. Substantial flexibility on top of what is in the gsDesign package is intended for selecting boundaries. Comments on usability and features are encouraged as this is still a young package.

Installation

Install the released version of gsDesign2 from CRAN:

install.packages("gsDesign2")

Or install the development version from GitHub with:

remotes::install_github("Merck/gsDesign2")

Use cases

Step 1: specifying enrollment and failure rates

This is a basic example which shows you how to solve a common problem. We assume there is a 4 month delay in treatment effect. Specifically, we assume a hazard ratio of 1 for 4 months and 0.6 thereafter. For this example we assume an exponential failure rate and low exponential dropout rate. The enroll_rate specification indicates an expected enrollment duration of 12 months with exponential inter-arrival times.

library(gsDesign2)

# Basic example

# Constant enrollment over 12 months
# Rate will be adjusted later by gsDesign2 NPH to get sample size
enroll_rate <- define_enroll_rate(duration = 12, rate = 1)

# 12 month median exponential failure rate in control
# 4 month delay in effect with HR=0.6 after
# Low exponential dropout rate
median_surv <- 12
fail_rate <- define_fail_rate(
  duration = c(4, Inf),
  fail_rate = log(2) / median_surv,
  hr = c(1, .6),
  dropout_rate = .001
)

The resulting failure rate specification is the following table. As many rows and strata as needed can be specified to approximate whatever patterns you wish.

fail_rate |> gt::gt()

Step 2: derive a fixed design with no interim analyses

Computing a fixed sample size design with 2.5% one-sided Type I error and 90% power. We specify a trial duration of 36 months with analysis_time. Enrollment duration is the sum of enroll_rate$duration. We used fixed_design() since there is a single analysis:

fd <- fixed_design_ahr(
  enroll_rate = enroll_rate,
  fail_rate = fail_rate,
  alpha = 0.025,
  power = 0.9,
  study_duration = 36,
  ratio = 1 # Experimental/control randomization ratio
)

The input enrollment rates have now been scaled to achieve power:

fd$enroll_rate |> gt::gt()

The failure and dropout rates remain unchanged from what was input. The summary is obtained below. The columns are:

  • Design: sample size derivation method.
  • N: sample size; generally you will round up to an even number.
  • Event: generally you will round up.
  • Bound: Z value for efficacy; this is the inverse normal from 1 - alpha.
  • alpha: 1-sided alpha level for testing.
  • Power: power corresponding to enrollment, failure rate, and trial targeted events.
fd |>
  summary() |>
  as_gt()

Step 3: group sequential design

We provide a simple example for a group sequential design that demonstrates a couple of features not available in the gsDesign package. The first is specifying analysis times by calendar time rather than information fraction. The second is not having an efficacy and futility bound at each analysis. This is in addition to having methods for non-proportional hazards as demonstrated in the fixed design above and again here.

We use an O’Brien-Fleming spending function to derive our efficacy bounds at 24 and 36 months. For futility, we simply require a nominally significant trend in the wrong direction ($p < 0.1$) after 8 months, a trend in favor of experimental treatment after 14 months ($Z > 0$) and no bound later ($Z = -\infty$). Thus, we have two efficacy analyses and two separate, earlier futility analysis. Power is set to 80% due to the somewhat aggressive futility bounds that are used for safety (analysis 1 half way through enrollment) and proof of concept (analysis 2). Such aggressive futility bounds may be desirable when a previous proof of concept for experimental treatment has not been established; essentially, this becomes a Phase II/III design with an interim evaluation of appropriate efficacy trends before completing the trial.

gsd <- gs_design_ahr(
  enroll_rate = enroll_rate,
  fail_rate = fail_rate,
  ratio = 1,
  alpha = 0.025,
  beta = 0.2, # 80% power; enables aggressive futility bound specified
  analysis_time = c(8, 14, 24, 36),
  binding = FALSE, # Non-binding futility bound
  upper = gs_spending_bound, # Use spending bound for efficacy; total_spend is normally alpha
  upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025),
  test_upper = c(FALSE, FALSE, TRUE, TRUE), # Only test efficacy after 1st analysis
  lower = gs_b, # Fixed Z-values will be provided for futility bound
  lpar = c(qnorm(0.1), 0, -Inf, -Inf)
)

Now we summarize the derived design. The summary table is further described in the vignette summarize group sequential designs in gt tables. Note that the design trend in favor of experimental treatment is very minor at 8 months due to the delayed effect assumption used (see AHR at analysis 1 in table). The design trend at 16 months is somewhat more favorable when we are looking for HR < 1 (favoring experimental treatment) for a proof of concept. Actual bounds and timing selected for a trial are situation dependent, but we hope the suggestions here are provocative for what might be considered.

gsd |>
  summary() |>
  as_gt()

Copy Link

Version

Install

install.packages('gsDesign2')

Monthly Downloads

741

Version

1.1.5

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Yujie Zhao

Last Published

June 27th, 2025

Functions in gsDesign2 (1.1.5)

gs_b

Default boundary generation
gs_design_rd

Group sequential design of binary outcome measuring in risk difference
gsDesign2-package

gsDesign2: Group Sequential Design with Non-Constant Effect
gs_bound_summary

Bound summary table
gs_design_wlr

Group sequential design using weighted log-rank test under non-proportional hazards
gs_create_arm

Create npsurvSS arm object
gs_design_ahr

Calculate sample size and bounds given targeted power and Type I error in group sequential design using average hazard ratio under non-proportional hazards
gs_cp_npe

Conditional power computation with non-constant effect size
gs_design_combo

Group sequential design using MaxCombo test under non-proportional hazards
gs_design_npe

Group sequential design computation with non-constant effect and information
gs_info_ahr

Information and effect size based on AHR approximation
gs_info_combo

Information and effect size for MaxCombo test
gs_power_npe

Group sequential bound computation with non-constant effect
gs_info_rd

Information and effect size under risk difference
gs_power_wlr

Group sequential design power using weighted log rank test under non-proportional hazards
gs_power_ahr

Group sequential design power using average hazard ratio under non-proportional hazards
gs_spending_bound

Derive spending bound for group sequential boundary
gs_power_combo

Group sequential design power using MaxCombo test under non-proportional hazards
gs_info_wlr

Information and effect size for weighted log-rank test
gs_power_rd

Group sequential design power of binary outcome measuring in risk difference
ppwe

Piecewise exponential cumulative distribution function
gs_spending_combo

Derive spending bound for MaxCombo group sequential boundary
gs_update_ahr

Group sequential design using average hazard ratio under non-proportional hazards
wlr_weight

Weight functions for weighted log-rank test
pw_info

Average hazard ratio under non-proportional hazards
summary.fixed_design

Summary for fixed design or group sequential design objects
s2pwe

Approximate survival distribution with piecewise exponential distribution
text_summary

Generates a textual summary of a group sequential design using the AHR method.
to_integer

Round sample size and events
fixed_design_ahr

Fixed design under non-proportional hazards
define_enroll_rate

Define enrollment rate
ahr_blinded

Blinded estimation of average hazard ratio
expected_time

Predict time at which a targeted event count is achieved
ahr

Average hazard ratio under non-proportional hazards
expected_accrual

Piecewise constant expected accrual
as_rtf

Write summary table of a fixed or group sequential design object to an RTF file
as_gt

Convert summary table of a fixed or group sequential design object to a gt object
expected_event

Expected events observed under piecewise exponential model
define_fail_rate

Define failure rate