Description Usage Arguments Value Examples
View source: R/simulation.rgs.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. (7) Weighted log-rank test is then performed for each simulated group sequential dataset.
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 | simulation.rgs(
nSim = 10000,
N = 672,
A = 21,
w = 1.5,
r = 1,
lambda0 = log(2)/12,
lambda1 = log(2)/12 * 0.65,
cuts = NULL,
dropOff0 = 0,
dropOff1 = 0,
targetEvents = NULL,
DCO = NULL,
sf = "LDOF",
overall.alpha = 0.025,
type1err = NULL,
logrank = "N",
fws.options = NULL,
H0 = "N",
Cox = "N",
Median = "N",
scanfreq0 = NULL,
scanfreq1 = NULL,
seed = 2022
)
|
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 |
lambda0 |
Hazard rates for control arm of intervals defined by cuts; for exponential(lambda0) distribution, lambda0 = log(2) / median; |
lambda1 |
Hazard rates for experimental arm for intervals; for exponential(lambda1) distribution, lambda1 = log(2) / median; For delayed effect under H1, lambda1 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 lamda0 = log(2) / m0 or lambda0 = rep(log(2) / m0, 2), lamda1 = c(log(2)/m0, log(2)/m0hr). treatment after 24 mo, so its hazard decreases 20%. Then, lambda0 = c(log(2)/m0, log(2)/m0, log(2)/m00.8), lambda1 = 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) |
dropOff0 |
Drop Off rate per month, eg, 1%, for control arm |
dropOff1 |
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 |
overall.alpha |
One-sided overall type I error, default 0.025. |
type1err |
Incremental type I error. sum(type1err) = overall.alpha. When targetEvents is NULL, type1err is required. |
logrank |
Indicator whether log-rank test is requested besides the weighted logrank tests. "Y" or "N". Default "Y". If "Y", the traditional log-rank test will be used based on survdiff() function. If "N", the weighted log-rank test with weighting function specified in fws will be used. |
H0 |
"Y" or "N" to indicate whether the simulation is for type I error |
Cox |
"Y" or "N" to indicate whether Cox regression model is requested to produce HR estimate |
Median |
"Y" or "N" to indicate whether median is requested to estimate. |
scanfreq0 |
A vector of scan frequency for control arm, eg, every 6 weeks for 2 scans, then every 9 weeks thereafter. scanfreq = c(rep(6, 2), rep(9, 1000))*7. Applicable for PFS data. |
scanfreq1 |
A vector of scan frequency for experimental arm, eg, every 6 weeks for 2 scans, then every 9 weeks thereafter. scanfreq = c(rep(6, 2), rep(9, 1000))*7. Applicable for PFS data. |
An object with a dataframe for each analysis including the following variables:
Power for each analysis
Overall power of the group sequential design
Simulation results for each simulated study data. An array with dimensions: nSim simulations X M testing strategies (fws.options) X K analyses X 5 variables:
z value
p value
analysis
rejection boundary
testing result (1 = positive; 0 = negative)
Power for each analysis using log-rank test. Available if logrank ="Y"
Overall power of the group sequential design using logrank test
Simulation results for each simulated study data using logrank test. nSim simulations X K analyses X 5 variables as above
A matrix with dimension (nSim, K). Date cutoff date for each analysis in each simulated trial.
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 | lr = function(s){1}
fh01 = function(s){1-s}
fh11 = function(s){s*(1-s)}
sfh01 = function(s){s1 = apply(cbind(s, 0.5), MARGIN=1,FUN=max); return(1-s1)}
#Example (1): Simulate 10 samples from proportional hazards scenario.
fws1 = list(IA1 = list(lr), FA = list(lr))
fws2 = list(IA1 = list(lr), FA = list(fh01))
fws3 = list(IA1 = list(fh01), FA = list(fh01))
fws4 = list(IA1 = list(lr), FA = list(lr, fh01))
fws5 = list(IA1 = list(lr), FA = list(lr, fh01, fh11))
fws6 = list(IA1 = list(lr, fh01), FA = list(lr, fh01))
fws7 = list(IA1 = list(sfh01), FA = list(lr, fh01))
#' alpha = f.alpha(overall.alpha=0.025, side = 1, sf="LDOF", targetEvents=c(60, 80))
m0 = 11.7
lambda0 = log(2) / m0
h0 = function(t){lambda0};
S0 = function(t){exp(-lambda0 * t)}
h1 = function(t){lambda0*0.745};
S1 = function(t){exp(-lambda0 *0.65* t)}
F.entry = function(t){(t/21)^1.5*as.numeric(t <= 21) + as.numeric(t > 21)}
G.ltfu = function(t){0}
f.logHR = function(t){log(0.745)}
#7 weighting strategies for exploration
fws = list(fws1, fws2, fws3, fws4, fws5, fws6, fws7)
#Simulations for exploring 7 weighting strategies
sim = simulation.rgs(nSim=2, N = 100, A = 21, w=1.5, r=1,
lambda0=log(2)/12, lambda1=log(2)/12*0.65,
cuts=NULL, targetEvents = c(60, 80),
sf = "LDOF", overall.alpha = 0.025, type1err = NULL,
logrank="Y", fws.options=NULL, Cox="Y", Median="Y")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.