Tutorials › Model-Informed Drug Development (MIDD) › Generating Virtual Trial Participants

Clinical Trial Simulation · Tutorial 276 of 596

Generating Virtual Trial Participants

Build virtual trial datasets that honor eligibility rules, planned sample size, randomization, and the specified baseline and outcome models.

Advanced 12 min read

What You'll Learn

  • Generate eligible participants by rejection sampling or direct conditional sampling.
  • Distinguish a fixed planned enrollment from a simulated number of eligible participants.
  • Apply a specified randomization scheme while preserving intended arm sizes.
  • Simulate individual outcomes conditional on assigned treatment and baseline values.
  • Diagnose common errors in eligibility, allocation, and outcome generation.

From a Trial Scenario to Virtual Participants

A trial-level simulation needs more than an efficacy model: it needs a set of participants to whom that model can be applied. Each virtual participant should represent a plausible person from the scenario’s target population, meet the protocol’s eligibility criteria, receive treatment according to the planned randomization, and have an outcome generated according to the specified outcome model. If any of these steps is misrepresented, the simulated trial may answer a different question from the one intended.

The goal here is to translate specified population distributions and trial rules into participant-level records. Treat the distributions and model parameters as fixed inputs for each scenario. This tutorial does not address uncertainty in those parameters or elaborate joint models for correlated characteristics; those require additional specification. Any independence assumption used here must be stated as part of the scenario, not silently imposed by the simulation code.

Definition: A virtual trial participant is one simulated individual record containing the characteristics needed to apply the protocol and outcome model. A virtual trial is a simulated set of such participants, with eligibility, enrollment, randomization, and outcomes generated according to prespecified rules. Planned enrollment \(n\) is the number of eligible participants to be randomized when the design fixes the trial size.

A useful sequence is: generate candidate characteristics from the target population; apply eligibility rules; continue until the planned number of eligible participants is enrolled; randomize those participants; and generate outcomes conditional on their characteristics and assigned treatment. When the scenario instead asks how many people must be screened to enroll a target number, the screening process itself is part of the quantity being simulated. These are different questions and should not be conflated.

Generating Participants Who Meet Eligibility Criteria

Let \(X\) denote the baseline characteristics of a candidate drawn from the specified target-population distribution \(f(x)\). Let \(E\) denote the event that the candidate meets every eligibility criterion. If candidates are generated from \(f(x)\) and retained only when eligible, their distribution is the population distribution conditional on eligibility:

$$ f(x\mid E)=\frac{f(x)I(x\in E)}{P(E)} $$

Here \(I(x\in E)\) equals 1 for an eligible candidate and 0 otherwise. The formula says that the retained distribution has zero probability outside the eligible region and is renormalized within it. Under independent candidate generation and a fixed eligibility rule, each retained candidate has this conditional distribution. Drawing until \(n\) eligible participants have been obtained therefore produces the planned number of participants from the eligible population.

This is rejection sampling: draw a candidate, evaluate the protocol criteria, retain an eligible candidate, and discard an ineligible one. It is simple and faithful to the specified population distribution, but can be inefficient if eligibility is rare. If the eligible fraction is \(q=P(E)\), then the expected number of candidates screened to enroll \(n\) people is \(n/q\), assuming independent candidate draws and a constant eligibility probability. A direct draw from the conditional distribution can be more efficient when it is available and correctly implemented.

Do not replace conditioning by clipping. For example, drawing a normally distributed laboratory value and changing every value below the eligibility threshold to that threshold creates an artificial pile-up at the cutoff. The result is not the original population conditional on eligibility. If a protocol criterion is based on several characteristics, apply the complete rule to each candidate; passing one criterion does not establish overall eligibility.

Worked Example: Rejection Sampling to a Fixed Enrollment

Suppose a scenario specifies baseline biomarker \(X\sim N(90,15^2)\), in units per liter, with eligibility requiring \(60\leq X\leq120\). The trial plans to randomize \(n=4\) eligible participants. For illustration, the candidate draws are 55, 72, 101, 124, 88, and 116.

Apply both bounds to each candidate. Values 55 and 124 are ineligible; values 72, 101, 88, and 116 are eligible. The first four eligible draws are therefore 72, 101, 88, and 116 units per liter. Stop candidate generation once those four eligible participants have been enrolled.

The number enrolled is four, not six: six is the number screened in this illustrative sequence. The accepted values are not altered to the nearest bound. In a full simulation, candidate values would be generated from the specified normal distribution, and this rejection rule would be repeated for every virtual trial.

Randomization and Planned Enrollment

Randomization is a separate step from eligibility. First identify the enrolled eligible participants; then assign treatments using the design’s stated allocation procedure. For a fixed total \(n\) and exact allocation counts, one implementation is to create the required number of treatment labels, randomly permute them, and assign the permuted labels to the enrolled participants. This preserves the planned arm sizes while making assignments random. If the design instead uses independent assignment with probability \(r\) to one arm, arm sizes can vary across simulated trials; that is not equivalent to fixed allocation.

Randomization should not depend on a participant’s simulated outcome. Nor should an implementation quietly assign the first half of the participant records to one arm and the remainder to another: record order is not randomization. If a scenario specifies strata or blocks, the assignment algorithm must reflect them. The essential requirement is to implement the design that was specified, rather than a convenient substitute.

Worked Example: Preserving a 1:1 Allocation

A trial enrolls \(n=6\) eligible participants and uses a fixed 1:1 allocation. The required treatment-label set contains three labels for treatment and three for control. Suppose a random permutation produces the participant order 4, 1, 6, 2, 5, 3 for those labels.

Assigning the permuted labels in that order gives participants 4, 1, and 6 to treatment and participants 2, 5, and 3 to control. The arm counts are \(3\) and \(3\), and every participant receives exactly one assignment. A new random permutation is generated for each simulated trial.

This procedure represents exact allocation. If instead each participant were independently assigned to treatment with probability \(0.5\), the number assigned to treatment would vary; for six participants it could be any integer from 0 through 6. That may be appropriate for a different design, but it would not preserve this trial’s planned 3:3 allocation.

Generating Outcomes From the Specified Model

Once treatment is assigned, generate each participant’s outcome from the specified outcome distribution conditional on the inputs in that model. For example, a continuous outcome might follow a normal distribution with a mean depending on treatment and baseline, and a residual standard deviation that is specified for the scenario. The model’s assumptions must be explicit: for instance, whether residuals are independent across participants and whether the residual variance is constant. Generate an outcome draw, not just the model-predicted mean, unless the scenario explicitly calls for deterministic predictions.

The following example uses a simple specified model. Its numerical inputs are hypothetical and are used only to demonstrate the calculation.

Worked Example: Simulating Continuous Outcomes

Suppose the outcome model, measured in points, is \(Y_i\mid X_i,A_i\sim N(\mu_i,2^2)\), where \(\mu_i=8+0.04(X_i-80)-1.5A_i\). Here \(X_i\) is a baseline value in units per liter, and \(A_i=1\) for treatment and \(A_i=0\) for control. Assume independent residual draws for different participants, as specified in this example. Four enrolled participants have the following baselines, assignments, and generated standard-normal residual values \(z_i\): \((70,0,-0.5)\), \((90,0,0.25)\), \((80,1,1.0)\), and \((100,1,-1.0)\).

For participant 1, \(\mu_1=8+0.04(70-80)-1.5(0)=7.6\). With \(z_1=-0.5\), the simulated outcome is \(Y_1=\mu_1+2z_1=7.6+2(-0.5)=6.6\) points.

For participant 2, \(\mu_2=8+0.04(90-80)=8.4\), so \(Y_2=8.4+2(0.25)=8.9\) points. For participant 3, \(\mu_3=8+0.04(80-80)-1.5=6.5\), so \(Y_3=6.5+2(1.0)=8.5\) points. For participant 4, \(\mu_4=8+0.04(100-80)-1.5=7.3\), so \(Y_4=7.3+2(-1.0)=5.3\) points.

The resulting outcomes are 6.6, 8.9, 8.5, and 5.3 points. Each is a model-based random draw, so a treated participant can have a higher outcome than a control participant even when the treatment term lowers the conditional mean. That is compatible with the model’s residual variability; the treatment coefficient describes a mean difference conditional on baseline, not a guaranteed ordering of individual outcomes.

Justification, Checks, and Failure Modes

The conditional distribution result follows directly from the definition of conditional probability. For any set \(B\) of baseline values,

$$ P(X\in B\mid E) =\frac{P(X\in B,\ E)}{P(E)} =\frac{\int_{B\cap E} f(x)\,dx}{P(E)}. $$

Thus an accepted candidate has density \(f(x)/P(E)\) within the eligible region and density zero outside it. Repeated independent candidate draws followed by the same eligibility rule yield repeated draws from this conditional distribution. Stopping after the \(n\)th accepted candidate fixes enrollment without changing the distribution of the accepted values.

Several checks can reveal mistakes before trial summaries are interpreted. Confirm that the enrolled count is exactly the planned \(n\), that every retained participant meets every criterion, and that the arm counts match the specified allocation when it is fixed. Check that generated baseline values are on the intended scale and that the eligible sample does not contain values outside the permitted range. For outcomes, verify that the calculation uses the correct treatment indicator, baseline units, and residual scale.

A mismatch between the simulated eligible distribution and the intended conditional distribution can indicate a coding error, a mistaken eligibility rule, or a very small accepted sample. A pile-up at a boundary may indicate clipping. An arm-count discrepancy may indicate that independent Bernoulli assignment was used where exact allocation was intended. Identical outcomes across participants may indicate that the model mean was used without residual draws. These checks diagnose implementation; they do not establish that the chosen population distributions or outcome model are scientifically adequate.

Common pitfall: “The planned enrollment is 100, so generate 100 population candidates and remove those who fail eligibility.” This can leave fewer than 100 randomized participants and therefore does not represent a trial planned to enroll 100 eligible people. For fixed eligible enrollment, continue screening until 100 eligible participants are obtained. Simulating a fixed screening cohort is appropriate only when that cohort size, rather than eligible enrollment, is the scenario of interest.

The main alternatives depend on which part of the process is fixed. Rejection sampling is transparent and generally easy to check; direct conditional sampling can be faster but requires a correct method for the conditional distribution. Exact allocation preserves arm counts, whereas independent treatment assignment permits those counts to vary. A fixed-enrollment simulation answers questions conditional on reaching the planned eligible sample; simulating a fixed screening cohort can address recruitment yield instead. These approaches are not interchangeable, and none can correct an incorrectly specified population or outcome model.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. A trial plans to randomize 20 eligible participants. If 25 candidate records are generated and 4 are ineligible, how many eligible participants remain, and what should the simulation do?
  2. Why does clipping every simulated baseline value below an eligibility threshold to the threshold fail to represent conditioning on eligibility?
  3. A fixed 2:1 allocation is planned for \(n=9\). What arm counts should a correctly implemented exact-allocation procedure produce?
  4. In the outcome model \(Y=\mu+2z\), a participant has \(\mu=7.2\) points and generated \(z=-0.5\). What outcome is simulated, and what does it represent?

Solutions. (1) There are \(25-4=21\) eligible participants, so the simulation can enroll 20 and stop; one eligible candidate is not needed. (2) Clipping places probability mass exactly at the threshold and changes the distribution, whereas conditioning retains only values in the eligible region and renormalizes their probabilities. (3) Exact 2:1 allocation gives 6 participants in one arm and 3 in the other. (4) \(Y=7.2+2(-0.5)=6.2\) points. This is one simulated outcome around the conditional mean, incorporating the specified residual draw.