sim_events_delay {nphRCT} | R Documentation |
Simulate survival data from a two-arm trial
Description
Simulate survival data from a two-arm trial with survival times on the control arm and experimental arm simulated from an exponential distribution or piecewise exponential distribution.
Usage
sim_events_delay(event_model, recruitment_model, n_c, n_e, max_cal_t)
Arguments
event_model |
List containing information to simulate event times, including:
|
recruitment_model |
List containing information to simulate recruitment times, including:
|
n_c |
Number of individuals on the control arm |
n_e |
Number of individuals on the event arm |
max_cal_t |
Calendar time at which the trial ends, all observations are censored at this time. |
Details
Survival times are simulated from an exponential distribution with rate parameter \lambda
,
f(t)=\lambda exp(-\lambda t)
. This distribution has a median value of log(2)/\lambda
;
this can be a useful fact when setting the rates lambda_c
and lambda_e
.
The survival times can be simulated from a piecewise exponential distribution, setting one/multiple
durations and \lambda
parameters for the control and experimental arms.
Recruitment is modeled using either the power model or the piecewise constant model.
The power model is defined as:
P(recruited\_before\_T) = (T / rec\_period) ^ {rec\_power}
, where
rec\_period
is the time at the end of recruitment period, and rec\_power
controls the rate of recruitment.
Alternatively, recruitment can be modelled using the piecewise constant model.
In the simple case with only one time period defined in rec_duration
, the times between each of the individuals entering follow-up
are samples from the exponential distribution with rate parameter \lambda
,
f(t)=\lambda exp(-\lambda t)
. The number of recruitment times defined in n_c
or n_e
is returned, regardless of the
length of duration rec_duration.
In the case with multiple time periods defined in rec_duration
, the number of events in each period is sampled from the
Poisson distribution P(K=k)=\lambda^k \exp{(-\lambda}/k!)
, where k
is the number of events. The rate parameter
\lambda
is equal to rec_rate
multiplied by the duration of the time period in rec_duration
. The recruitment times
are then sampled uniformly from the corresponding time period. In the case that
insufficient recruitment times have been simulated by the end of the last time period, the additional recruitment times will be
simulated after the end of the last time period.
All observations are censored at the calendar time defined in argument max_cal_t
.
Value
Data frame with columns event_time
, event_status
(1
= event, 0
= censored), and treatment arm indicator group
.
Examples
library(nphRCT)
set.seed(1)
sim_data <- sim_events_delay(
event_model=list(
duration_c = 36,
duration_e = c(6,30),
lambda_c = log(2)/9,
lambda_e = c(log(2)/9,log(2)/18)
),
recruitment_model=list(
rec_model="power",
rec_period = 12,
rec_power = 1
),
n_c=50,
n_e=50,
max_cal_t = 36
)