Description Usage Arguments Value Examples
View source: R/simulation.pwexp.R
Simulate Randomized two-arm trial data with the following characteristics: (1) randomization time (entry time) is generated according to the specified non-uniform accrual pattern, i.e. the cumulative recruitment at calendar time t is (t/A)^w with weight w and enrollment complete in A months. w = 1 means uniform enrollment, which is usually not realistic due to graduate sites activation process. (2) Survival time follows piece-wise exponential distribution for each arm. (3) N total patients with r:1 randomization ratio (4) Random drop off can be incorporated into the censoring process. (5) Data cutoff dates are determined by specified vector of target events for all analyses. (6) A dataset is generated for each analysis according to the specified number of target events. Multiple analyses can be specified according to the vector of targetEvents, eg, targetEvents = c(100, 200, 300) defines 3 analyses at 100, 200, and 300 events separately.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
nSim |
Number of trials |
N |
Total number patients in two arms. |
A |
Total accrual period in months |
w |
Weight parameter in cumulative enrollment pattern. The cumulative enrollment at month t is (t / A)^w, eg, at month 6, the enrollment is N*(6/24)^2 = N/16 for 24 months planned accrual period. |
r |
Randomization ratio r:1, where r refers to the experimental arm, eg, r=2 in 2:1 ratio |
lam0 |
Hazard rates for control arm of intervals defined by cuts; for exponential(lam0) distribution, lam0 = log(2) / median; |
lam1 |
Hazard rates for experimental arm for intervals; for exponential(lam1) distribution, lam1 = log(2) / median; For delayed effect under H1, lam1 is a vector (below). |
cuts |
Timepoints to form intervals for piecewise exponential distribution. For example, experimental arm has hr = 0.6 after delay, then cuts = 6, and lam0 = log(2) / m0 or lam0 = rep(log(2) / m0, 2), lam1 = c(log(2)/m0, log(2)/m0hr). treatment after 24 mo, so its hazard decreases 20%. Then, lam0 = c(log(2)/m0, log(2)/m0, log(2)/m00.8), lam1 = c(log(2)/m0, log(2)/m0hr, log(2)/m0hr), and cuts = c(6, 24), which forms 3 intervals (0, 6), (6, 24), (24, infinity) |
drop0 |
Drop Off rate per month, eg, 3% every year for control arm, then drop0=0.03/12 |
drop1 |
Drop Off rate per month, eg, 1%, for experimental arm |
targetEvents |
A vector of target events is used to determine DCOs. For example, 397 target events are used to determine IA DCO; and 496 events are used to determine the FA cutoff. |
DCO |
A vector of data cut-off time in months, calculated from first subject in. Default NULL. The date cut-off times will be determined by targetEvents. If provided, then the targetEvents will be ignored. |
An object with a dataframe for each analysis including the following variables:
sequence number of simulated dataset;
treatment group with values of "control" and "experimental"
Time of randomization in calendar time
the time when event/censoring occurred in calendar time
Survival time for analysis, = calendarTime - enterTime
censor status (0=event; 1=censor) before administrative censoring due to data cut
Data CutOff Time (DCO);
Survival time after cut
Censor status after cut
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #Example (1): Simulate 10 samples from proportional hazards scenario.
#Total 600 pts, 1:1 randomization, control median OS 12 mo;
#HR = 0.65, enrollment 24 months, weight 1.5, no drop offs;
#IA and FA are performed at 400 and 500 events respectively.
sim.ph = simulation.pwexp(nSim=10, N = 600, A = 24, w=1.5, r=1, lam0=log(2)/12, lam1= log(2)/12*0.65, cuts=NULL, drop0= 0, drop1= 0, targetEvents = c(400, 500))
km.IA<-survival::survfit(survival::Surv(survTimeCut,1-cnsrCut)~treatment,data=sim.ph[[1]][sim==1,])
plot(km.IA,xlab="Month Since Randomization",ylab="Survival",lty=1:2,xlim=c(0,36))
km.FA<-survival::survfit(survival::Surv(survTimeCut,1-cnsrCut)~treatment,data=sim.ph[[2]][sim==1,])
plot(km.FA,xlab="Month Since Randomization",ylab="Survival",lty=1:2,xlim=c(0,36))
#Example (2): Simulate 10 samples with delayed effect at month 6;
#Total 600 pts, 1:1 randomization, control median OS 12 mo;
#HR = 0.65, enrollment 24 months, weight 1.5, no drop offs;
#IA and FA are performed at 400 and 500 events respectively.
sim.delay6 = simulation.pwexp(nSim=10, N = 600, A = 24, w=1.5, r=1, lam0=log(2)/12, lam1= c(log(2)/12,log(2)/12*0.65), cuts=6, drop0= 0, drop1= 0, targetEvents = c(400, 500))
km.IA<-survival::survfit(survival::Surv(survTimeCut,1-cnsrCut)~treatment,data=sim.delay6[[1]][sim==1,])
plot(km.IA,xlab="Month Since Randomization",ylab="Survival",lty=1:2,xlim=c(0,36))
km.FA<-survival::survfit(survival::Surv(survTimeCut,1-cnsrCut)~treatment,data= sim.delay6[[2]][sim==1,])
plot(km.FA,xlab="Month Since Randomization",ylab="Survival",lty=1:2,xlim=c(0,36))
#Example (3): Simulate 10 samples with delayed effect at month 6
#Control arm has crossover to subsequent IO after 24 mo, so its hazard decreases 20%.
#control arm has constant hazard (median 11.7 mo) and experimental arm has
#hr = 1 and 0.65 at intervals (0, 6) and (6, 24) respectively.
#HR = 0.65, enrollment 24 months, weight 1.5, no drop offs;
#IA and FA are performed at 400 and 500 events respectively.
crossEffect = 0.8 #Hazard ratio in control arm (after crossover vs before crossover)
lam0 = log(2)/12*c(1, 1, crossEffect); lam1 = log(2)/12*c(1, hr, hr)
sim.delay6crs=simulation.pwexp(nSim=10,N=600,A=24,w=1.5,r=1,lam0=lam0, lam1=lam1,cuts=c(6, 24),drop0=0,drop1=0, targetEvents=c(400, 500))
km.IA<-survival::survfit(survival::Surv(survTimeCut,1-cnsrCut)~treatment,data=sim.delay6crs[[1]][sim==1,])
plot(km.IA,xlab="Month Since Randomization",ylab="Survival",lty=1:2,xlim=c(0,36))
km.FA<-survival::survfit(survival::Surv(survTimeCut,1-cnsrCut)~treatment,data= sim.delay6crs[[2]][sim==1,])
plot(km.FA,xlab="Month Since Randomization",ylab="Survival",lty=1:2,xlim=c(0,36))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.