Why Validate a Delayed-Outcome Simulation?
A simulation can produce plausible-looking trial results while implementing the wrong time scale, censoring rule, or intermediate-outcome assessment schedule. Validation asks a narrower question than whether the simulated trial is clinically realistic: does the code generate the outcomes implied by its stated assumptions? For delayed outcomes, this means checking each stage of the data-generating process before trusting downstream arm-selection frequencies.
The central strategy is to create benchmarks whose answers are known independently of the full simulation. Some are exact probabilities, such as the chance of observing an event before censoring. Others are limiting cases: for example, if every participant has enough follow-up, all scheduled intermediate outcomes should be mature. Agreement within expected Monte Carlo variation is reassuring, but it does not prove that the model is appropriate for a real trial.
Check Accrual and Outcome Maturity First
Suppose a fixed cohort of \(n\) participants has entry times independently drawn from a uniform distribution on \([0,A]\), where \(A\) is the accrual duration. Then each entry time \(E_i\) has mean \(A/2\), variance \(A^2/12\), and probability \(t/A\) of occurring by time \(t\), for \(0\le t\le A\). Thus, the number enrolled by \(t\) follows a binomial distribution with parameters \(n\) and \(t/A\). These benchmarks apply to this uniform-entry model, not automatically to a Poisson accrual process or to fixed scheduled enrollment dates.
If an intermediate outcome is assessed after a fixed lag \(L\) from enrollment, it is mature by the end of accrual only when \(E_i+L\le A\). For \(0\le L\le A\), the maturity probability is \((A-L)/A\). The maturity count is binomial under independent uniform entry times. At an earlier calendar-time look \(t\), apply the same reasoning to the participants actually enrolled by \(t\): an outcome is mature if \(E_i\le t-L\). Checking the number enrolled and the number mature separately helps locate errors in the accrual clock versus the assessment clock.
Worked Example: Auditing Accrual and Maturity
Consider a hypothetical fixed cohort of 1,000 participants whose entry times are independent and uniform over 10 weeks. An intermediate assessment occurs 3 weeks after entry. Check two benchmarks: entry by week 4 and maturity by the end of week 10.
For entry by week 4, each participant has probability \(4/10=0.40\) of having entered. The count \(N_4\) therefore has mean \(1{,}000(0.40)=400\) and standard deviation \(\sqrt{1{,}000(0.40)(0.60)}=15.49\). If the simulation gives 386 entries, the difference from expectation is \(386-400=-14\), or about \(-14/15.49=-0.904\) standard deviations. That discrepancy is compatible with ordinary simulation variation.
By week 10, an outcome is mature if entry occurred by week \(10-3=7\). The maturity probability is \(7/10=0.70\), giving an expected mature count of 700 and standard deviation \(\sqrt{1{,}000(0.70)(0.30)}=14.49\). A simulated count of 713 differs by 13, or about \(0.897\) standard deviations. Both checks are reassuring for this run; they do not establish that the assumed uniform accrual or fixed assessment lag is appropriate for a particular trial.
Validate Event Times and Censoring Together
A useful analytic check assumes an event time \(T\sim\operatorname{Exp}(\lambda)\) and an independent censoring time \(C\sim\operatorname{Exp}(\mu)\), with positive rates \(\lambda\) and \(\mu\). The observed follow-up is \(U=\min(T,C,\tau)\), where \(\tau\) is an administrative follow-up limit, and the event indicator is \(\delta=1\) if \(T\le C\) and \(T\le\tau\), and 0 otherwise. Independence and the exponential distributions are substantive assumptions of this benchmark; if the simulation uses other distributions or dependent event and censoring times, these formulas do not apply unchanged.
The density that the event occurs at time \(t\) before censoring is \(\lambda e^{-\lambda t}e^{-\mu t}\). Integrating this density from 0 to \(\tau\) gives the probability of an observed event. By symmetry, replacing \(\lambda\) with \(\mu\) gives the probability that random censoring occurs first by \(\tau\). If neither happens by \(\tau\), both times exceed the limit.
These three mutually exclusive categories sum to one. In a usual record with administrative follow-up, however, the observed censoring indicator \(\delta=0\) combines random censoring before the event with participants who reach \(\tau\) without either time occurring. The simulation should be checked against the correct category definition, not just a loosely labelled “censoring rate.”
Worked Example: Finding a Censoring-Model Discrepancy
Suppose a hypothetical simulation uses \(\lambda=0.10\) events per month, \(\mu=0.02\) censorings per month, and \(\tau=6\) months, with independent exponential event and censoring times. For 100,000 independently generated participant records, the simulated event proportion is 0.2573. Calculate the event benchmark and decide whether the discrepancy is ordinary Monte Carlo variation.
The event probability is \(P(\delta=1)=\frac{0.10}{0.10+0.02}[1-e^{-(0.10+0.02)6}]\). Substitution gives \(\frac{0.10}{0.12}(1-e^{-0.72})\). Since \(e^{-0.72}\approx0.48675\), this is \((0.10/0.12)(0.51325)\approx0.4277\).
For \(n=100{,}000\) independent records, the standard error of the simulated event proportion under this benchmark is approximately \(\sqrt{0.4277(1-0.4277)/100{,}000}=0.001565\). The observed difference is \(0.2573-0.4277=-0.1704\), approximately \(-109\) standard errors. This is far too large to attribute to ordinary Monte Carlo variation. The event-time generation, censoring generation, units, and event-indicator definition should be investigated before the simulation is used for trial-level conclusions.
As a further check, the benchmark probability of random censoring before the event by month 6 is \((0.02/0.12)(1-e^{-0.72})\approx0.08554\), and the probability that both times exceed 6 months is \(e^{-0.72}\approx0.4868\). Together with the event probability, these sum to 1. The overall observed censoring probability, including administrative censoring at 6 months, is \(1-0.4277=0.5723\).
Check Intermediate Outcomes and Arm Selection
A maturity check should be made before checking the intermediate-outcome values or selection decision. For example, a binary response that is generated only after an assessment lag must not be counted as observed before that lag. Among mature participants, compare response proportions with the model’s specified probabilities, accounting for the mature sample size. When the outcome is a binary variable with response probability \(p\) among \(m\) independently generated mature participants, its response count has mean \(mp\) and standard deviation \(\sqrt{mp(1-p)}\).
Selection frequencies can also have exact benchmarks in small, deliberately simplified cases. Enumerating every possible outcome is valuable because it tests the selection rule, including ties, without relying on a noisy large simulation. The following hypothetical example assumes independent arm outcomes and a rule that selects the arm with the larger number of responses, breaking ties by a fair random choice.
Worked Example: Exact Benchmark for an Arm-Selection Frequency
Suppose arms A and B each have two mature participants. Independently, responses follow \(X\sim\operatorname{Bin}(2,0.75)\) in A and \(Y\sim\operatorname{Bin}(2,0.25)\) in B. The rule selects A if \(X>Y\), selects B if \(Y>X\), and uses a fair coin if \(X=Y\). Find the probability that A is selected.
The probabilities of \(X=0,1,2\) are \(1/16,6/16,9/16\); those of \(Y=0,1,2\) are \(9/16,6/16,1/16\). By independence, the joint-probability numerators over denominator 256 for the cases \(X>Y\), namely \((1,0),(2,0),(2,1)\), are \(6\times9=54\), \(9\times9=81\), and \(9\times6=54\). Therefore \(P(X>Y)=(54+81+54)/256=189/256=0.7383\).
The tie cases \((0,0),(1,1),(2,2)\) have numerators \(1\times9=9\), \(6\times6=36\), and \(9\times1=9\). Thus \(P(X=Y)=54/256\). A fair tie-break gives \(P(\text{A selected})=P(X>Y)+\frac12P(X=Y)=(189+27)/256=216/256=0.8438\).
Across 10,000 independent simulated trials, the standard error of the selection proportion under this benchmark is \(\sqrt{0.84375(1-0.84375)/10{,}000}=0.003631\). A hypothetical simulated frequency of 0.842 differs from 0.84375 by \(-0.00175\), about \(-0.482\) standard errors. This is compatible with Monte Carlo variation. The exact benchmark depends on the stated independence, response probabilities, mature sample sizes, and random tie-breaking rule.
A Practical Validation Sequence
Validation is more informative when the data-generating process is checked in stages rather than only through the final selection result. A mismatch in selection can originate in accrual, outcome maturity, event generation, or the selection code itself. The sequence below localizes the source.
Write down the accrual distribution, time origin, event and censoring distributions, dependence assumptions, administrative cutoffs, assessment lag, and tie-breaking rule that the code is meant to implement.
Compare entry-time summaries and counts with their distributional benchmarks. Check event and censoring categories and inspect event-time summaries against the assumed model.
At each analysis time, compare the number eligible for assessment with the number implied by the entry-time and lag rules. Confirm that immature outcomes do not enter the selection statistic.
Use small sample sizes or limiting cases where every possible outcome and the resulting selection probability can be computed exactly.
For each estimated probability, calculate its Monte Carlo SE and examine discrepancies on that scale. Increase the number of replications when estimates are too imprecise for the intended comparison.
Diagnostics, Alternatives, and Limitations
A standardized discrepancy such as \((\hat p-p)/\sqrt{p(1-p)/n}\) helps describe the size of a difference for an independently simulated binary outcome. It is a diagnostic, not a universal pass-or-fail rule. A discrepancy of a few standard errors can occur by chance, especially when many checks are performed; a very large discrepancy, such as the one in the event example, signals a likely implementation or specification problem. For counts or continuous summaries, use the appropriate benchmark standard error instead.
Plots add information that a single average can hide. Compare an empirical event-time distribution with its theoretical cumulative distribution, and inspect accrual and maturity counts by time rather than only at one endpoint. A time-unit error may preserve a rank ordering while distorting the distribution. Also compare a small hand-calculated case with code output; this is often more decisive than repeating a large simulation.
Analytic benchmarks are generally the clearest checks when available, while an independently written reference implementation can check more complicated logic. The latter is not a mathematical guarantee: two implementations may share the same mistaken assumption or coding convention. Limiting cases are useful when exact formulas are unavailable, such as checking that the event proportion approaches zero as \(\lambda\) approaches zero, or that all outcomes are mature when every entry precedes the look by at least \(L\). These checks should complement, not replace, direct benchmarks.
The formulas in this tutorial rely on stated assumptions. Uniform accrual does not represent every enrollment process; independent exponential censoring does not cover informative censoring or arbitrary hazards; and an exact selection calculation for two small arms does not establish the correctness of a more complex rule. Further, a simulation may pass its code checks while still using implausible model inputs. Validation supports confidence that the programmed model matches its specification; it cannot establish that the specification describes the clinical setting well.
Check Your Understanding
For each question, work out the benchmark before consulting the solution.
- Under uniform accrual over 12 months, what proportion of a fixed cohort is expected to have entered by month 9?
- With an assessment lag of 4 months and accrual ending at month 12, what proportion is expected to have a mature assessment by the end of accrual?
- For independent exponential event and censoring times with rates \(\lambda=0.08\) and \(\mu=0.02\) per month, what is the probability of random censoring before the event by month 5?
- Why should a simulated event proportion of 0.2573 not be considered a close match to the event benchmark in the worked censoring example?
- In the small arm-selection example, why does the probability that A is selected exceed \(P(X>Y)\)?
Solutions. (1) The entry proportion is \(9/12=0.75\). (2) Maturity requires entry by month \(12-4=8\), so the expected proportion is \(8/12=0.6667\). (3) The random-censoring-first probability is \(\frac{0.02}{0.08+0.02}[1-e^{-(0.08+0.02)5}]=0.2(1-e^{-0.5})\approx0.07869\). (4) The benchmark is approximately 0.4277, with Monte Carlo SE approximately 0.001565 for 100,000 records; the difference \(-0.1704\) is about 109 SEs, far beyond ordinary Monte Carlo variation. (5) A is also selected on ties, with probability one half of \(P(X=Y)=54/256\); hence its probability is \(189/256+27/256=216/256=0.8438\).