Condition System for Triggering Milestones in a Trial

knitr::opts_chunk$set(
  collapse = TRUE,
  cache = TRUE,
  cache.path = 'cache/conditionSystem/',
  comment = '#>',
  dpi = 300,
  out.width = '100%'
)
library(TrialSimulator)

In clinical trial simulations, it is often necessary to specify when certain actions should be taken. For example, a trial may require interim data reviews when a predefined number of surrogate endpoint events occur to support dose selection. More complex triggers can be defined based on event numbers of one or multiple endpoints, calendar time, the number of enrolled patients, or a combination of multiple conditions. These triggers may govern critical analyses such as futility assessments, sample size re-assessment, interim analyses, and final evaluations, at various trial milestones.

To facilitate this process, TrialSimulator provides an intuitive condition-based system for defining milestone triggers. It supports logical operations (& for AND and | for OR), allowing users to specify complex conditions seamlessly. The simulator is then automatically determines the appropriate time points and executes user-defined actions accordingly.

Currently, TrialSimulator provides three key functions to define the earliest possible time for triggering a milestone:

The following sections illustrate various ways to define milestone triggers using these functions, which could be passed to the argument when of milestone().

A trial has been running for 6 months

## Note: the unit of time depends on the context of a trial
##       It is users responsibility to align it with trial's parameters
calendarTime(time = 6)

At least 520 patients have been enrolled

enrollment(n = 520)

At least 400 patients have been enrolled, and each has received a minimum of 3 weeks of treatment

enrollment(n = 400, min_treatment_duration = 3)

At least 340 PFS events are observed

## condition is based on number of event in the placebo arm
## Note: 'pfs' is the name of the endpoint, i.e., endpoints(name = 'pfs', ...)
## Note: 'pbo' is the name of the placebo arm, i.e., arm(name = 'pbo', ...)
eventNumber(endpoint = 'pfs', n = 340, arms = 'pbo')

## condition can be based on number of event in specific arms
eventNumber(endpoint = 'pfs', n = 340, arms = c('pbo', 'trt'))

## condition can be based on number of event in the trial
## Note: for example, a trial of more than two arms. 
##       Here the number of PFS events are counted on all arms in trial
eventNumber(endpoint = 'pfs', n = 340)

Other examples

## observe at least 200 OS events on at least 500 enrolled patients, or
## the trial has been running for at least 12 months
(enrollment(n = 500) & eventNumber(endpoint = 'os', n = 200)) | 
  calendarTime(time = 12)

## observe 320 OS or 480 PFS event when the trial has been running for 6 months
calendarTime(time = 6) & 
  (eventNumber('os', n = 320) | eventNumber('pfs', n = 480))


Try the TrialSimulator package in your browser

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

TrialSimulator documentation built on Nov. 5, 2025, 7:22 p.m.