Learn R Programming

simtrial

simtrial is a fast and extensible clinical trial simulation framework for time-to-event endpoints.

Installation

The easiest way to get simtrial is to install from CRAN:

install.packages("simtrial")

Alternatively, to use a new feature or get a bug fix, you can install the development version of simtrial from GitHub:

# install.packages("remotes")
remotes::install_github("Merck/simtrial")

Overview

simtrial is intended to be a general purpose tool for simulating fixed, group sequential or adaptive clinical trials. It allows stratified populations and flexible parameters for generating enrollment, event times, dropout times. It takes care of bookkeeping to enable easily going from data generation to creating analysis datasets for evaluation of standard or innovative designs and testing procedures. For a single endpoint, it will easily generate trials with multiple arms (e.g., a single or multiple experimental arms versus a common control) and multiple study populations (e.g., overall population and biomarker positive). While tools are built into the package for logrank and weighted logrank tests, arbitrary testing and estimation procedures are easily applied. In addition to weighted logrank tests, we support combinations of weighted logrank tests (e.g., the MaxCombo test). The package used piecewise constant enrollment, failure and dropout rates as a simple model able to approximate arbitrary distributions easily. This model also enables simulating non-proportional hazards assumptions that are transparent for users to explain to non-statistical collaborators.

simtrial is designed with a core philosophy of basing most computations on efficient table transformations and to have a package that is easy to qualify for use in regulated environments. It utilizes the blazingly fast data.table for tabular data processing, enhanced by C++ implementations to ensure optimal performance. However, it does not require the user to be a data.table or C++ user.

Initial areas of focus are:

  • Generating time-to-event data for stratified trials using piecewise constant enrollment and piecewise exponential failure rates. Both proportional and non-proportional hazards are supported. Under proportional hazards, the assumptions are along the lines of those used by Lachin and Foulkes as implemented in gsDesign for deriving group sequential designs.
  • Setting up data cutoffs for (interim and final) analyses.
  • Support for weighted logrank tests with arbitrary weighting schemes, specifically supporting the Fleming-Harrington set of tests, including the logrank test.

Future developments

Expectations for future development include:

  • Provide a test suite to document that the package is fit for use in a regulatory environment.
  • Further examples.

Copy Link

Version

Install

install.packages('simtrial')

Monthly Downloads

761

Version

1.0.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Yujie Zhao

Last Published

June 11th, 2025

Functions in simtrial (1.0.0)

get_cut_date_by_event

Get date at which an event count is reached
fit_pwexp

Piecewise exponential survival estimation
ex3_cure_with_ph

Time-to-event data example 3 for non-proportional hazards working group
ex5_widening

Time-to-event data example 5 for non-proportional hazards working group
randomize_by_fixed_block

Permuted fixed block randomization
multitest

Perform multiple tests on trial data cutting
ex6_crossing

Time-to-event data example 6 for non-proportional hazards working group
sim_fixed_n

Simulation of fixed sample size design for time-to-event endpoint
rmst

RMST difference of 2 arms
rpwexp_enroll

Generate piecewise exponential enrollment
mb_delayed_effect

Simulated survival dataset with delayed treatment effect
rpwexp

The piecewise exponential distribution
mb

Magirr and Burman weighting function
maxcombo

MaxCombo test
summary.simtrial_gs_wlr

Summary of group sequential simulations.
milestone

Milestone test for two survival curves
rmst_two_arm

Calculate RMST difference
simtrial-package

simtrial: Clinical Trial Simulation
rmst_single_arm

Calculate RMST for a single cut-off time point
sim_pw_surv

Simulate a stratified time-to-event outcome randomized trial
sim_gs_n

Simulate group sequential designs with fixed sample size
to_sim_pw_surv

Convert enrollment and failure rates from sim_fixed_n() to sim_pw_surv() format
wlr

Weighted logrank test
early_zero

Zero early weighting function
check_args

Check argument types, length, or dimension
cut_data_by_date

Cut a dataset for analysis at a specified date
create_test

Create a cutting test function
cut_data_by_event

Cut a dataset for analysis at a specified event count
counting_process

Process survival data into counting process format
create_cut

Create a cutting function
as_gt

Convert summary table to a gt object
get_analysis_date

Derive analysis date for interim/final analysis given multiple conditions
ex2_delayed_effect

Time-to-event data example 2 for non-proportional hazards working group
ex1_delayed_effect

Time-to-event data example 1 for non-proportional hazards working group
fh

Fleming-Harrington weighting function
ex4_belly

Time-to-event data example 4 for non-proportional hazards working group