Simulate dropouts (patient discontinuation) during the trial
Source:R/simulate_dropout.R
simulate_dropout.RdThis function simulates dropout times for patients, i.e., when patients prematurely leave the study. It can incorporate an increased dropout hazard for patients experiencing an adverse event (AE), representing dropouts related to side effects or other issues.
Arguments
- data
A data frame of patients. Optionally includes columns for adverse events or others; not required.
- dropout_rate
Numeric between 0 and 1, the overall proportion of patients expected to drop out by the end of follow-up (study duration).
- study_duration
Numeric, the length of follow-up (time units) for the trial. Required for calibrating dropout times.
- p_ae
Numeric between 0 and 1, probability that a patient experiences a certain serious adverse event that can increase dropout risk (default = 0).
- dropout_hr_ae
Numeric, hazard ratio for dropout if the patient had an adverse event vs no event (default = 1, meaning no increase). For example, 2.0 means patients with the AE drop out at twice the hazard.
Value
The input data frame with additional columns:
SeriousAE: Logical (TRUE/FALSE) indicating whether the patient had the simulated adverse event.DropoutTime: The time of dropout for those who dropped out, orNAif the patient did not drop out before study end.Dropped: Logical flag indicating if the patient dropped out (TRUE) or not (FALSE) bystudy_duration.
Details
Dropout times are modeled with an exponential distribution. The rate is set such that dropout_rate of patients (without the special AE) would drop out by study_duration (assuming an exponential survival for dropout). If dropout_hr_ae > 1, patients with the adverse event have a higher dropout hazard. The adverse event occurrence is simulated independently for each patient with probability p_ae. This allows simulating dropouts related to side effects (an original feature not present in many other packages). All patients with dropout_rate = 1 (100% dropout) are assigned a random dropout time before study_duration.
Patients who experience an event (e.g., death) prior to dropping out should be considered as not dropping out (their participation ended due to the event). The function does not remove such patients, but subsequent analysis (e.g., in ADSL) will mark their event time and ignore the dropout.
Examples
df <- simulate_patients(5)
df <- simulate_allocation(df)
# Simulate 20% dropout rate by 12 months, with 10% having serious AEs doubling dropout hazard
df <- simulate_dropout(df, dropout_rate = 0.2, study_duration = 12, p_ae = 0.1, dropout_hr_ae = 2)
head(df[c("DropoutTime","Dropped","SeriousAE")])
#> DropoutTime Dropped SeriousAE
#> 1 1.396007 TRUE FALSE
#> 2 10.062092 TRUE FALSE
#> 3 NA FALSE TRUE
#> 4 NA FALSE FALSE
#> 5 NA FALSE TRUE