Description Usage Arguments Details Value References See Also Examples
View source: R/oxy-simu.trial.R View source: R/simu.trial.R
simu.trial
simulates survival data allowing flexible input
of design parameters. It supports both event-driven design and fixed study duration
design.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
type |
indicates whether event-driven trial (" |
trial_param |
a vector of length 3 with components for required subject size, enrollment
time and required number of events (" |
bsl_dist |
indicates the survival distribution for control group, option:
c(" |
bsl_param |
a vector of length 2 with the shape and rate (scale) parameter for the survival distribution of control group. See details. |
drop_param0 |
a vector of length 2 with shape and scale parameter for the weibull distribution of drop-out time for control group |
drop_param1 |
a vector of length 2 with shape and scale parameter for the weibull distribution of drop-out time for treatment group |
entry_pdf0 |
a function describing the pdf of the entry time for control. Default: uniform enrollment |
entry_pdf1 |
a function describing the pdf of the entry time for treatment. |
HR_fun |
a function describing the hazard ratio function between treatment and control group |
ratio |
allocation ratio between treatment and control group.
For example, |
upInt |
a value indicating the upper bound used in the |
summary |
a logical indicating whether basic information summary is printed to the console or not, Default: TRUE |
The loglogistic distribution for the event time has the survival function S(x)=b^a/(b^a+x^a) and hazard function λ(x)=a/b(x/b)^(a-1)/(1+(t/b)^a),, where a is the shape parameter and b is the scale parameter. The weibull distribution for event time and drop-out time has the survival function f(x)=exp(-(xb)^a) and hazard function λ(x)=ab(xb)^a-1, where a is the shape parameter and b is the rate parameter. The median of weibull distribution is (ln(2)^(1/a)/b). If drop out or loss to follow-up are do not need to be considered, a very small rate parameter b can be chosen such that the median time is greatly larger than the study duration. The default entry time is uniformly distributed within the enrollment period by default. Other options are allowed through providing the density function.
The simu.trial
function simulates survival times for control and
treatment groups separately. The control survival times are drawn from standard parametric
distribution (Weibull, Loglogistic). Let λ_1(t) and λ_0(t)
denote the hazard function for treatment and control. It is assumed that
λ_1(t)/λ_0(t)=g(t), where g(t) is the user-defined
function, describing the change of hazard ratio over time. In case of proportional
hazards, g(t) is a constant. The survival function for treatment group
is S_1(t)=exp(-\int_0^t g(s)λ_0(s)ds). The Survival time T is
given by T=S_1^(-1)(U), where U is drawn from uniform (0,1). More details
can be found in Bender, et al. (2005). Function uniroot
from
stats
package is used to generate the random variable. The argument
upInt
in simu.trial
function corresponds to the upper end point
of the search interval and it can be adjusted by user if the default value 100
is not appropriate. More details can be found in help file of uniroot
function.
A list containing the following components
data
: a dataframe (simulated dataset) with columns:
identifier number from 1:n, n is the total sample size
group variable with 1 indicating treatment and 0 indicating control
observed survival time, the earliest time among event time, drop-out time and end of study time
censoring indicator with 1 indicating censor and 0 indicating event
description of the cnsr
status, including three options-
drop-out, event and end of study. Both drop-out and end of study are considered as
censor.
event indicator with 1 indicating event and 0 indicating censor
time when the patient is enrolled in the study
a list of summary information of the trial including
type
a character indicating input design type - event
or time
entrytime
a number indicating input enrollment period
maxob
a number indicating the maximum study duration. For time
type of design, the value is equal to the enrollment period plus the follow-up
period. For event
type of design, the value is the calendar time of the
last event.
Bender, R., Augustin, T., & Blettner, M. (2005). Generating survival times to simulate Cox proportional hazards models. Statistics in medicine, 24(11), 1713-1723.
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 | # total sample size
N <- 300
# target event
E <- 100
# allocation ratio
RR <- 2
# enrollment time
entry <- 12
# follow-up time
fup <- 18
# shape and scale parameter of weibull for entry time
b_weibull <- c(1,log(2)/18)
# shape and scale parameter of weibull for drop-out time
drop_weibull <- c(1,log(2)/30)
# hazard ratio function (constant)
HRf <- function(x){0.8*x^0}
### event-driven trial
set.seed(123445)
data1 <- simu.trial(type="event",trial_param=c(N,entry,E),bsl_dist="weibull",
bsl_param=b_weibull,drop_param0=drop_weibull,HR_fun=HRf,
ratio=RR)
### fixed study duration
set.seed(123445)
data2 <- simu.trial(type="time",trial_param=c(N,entry,fup),bsl_dist="weibull",
bsl_param=b_weibull,drop_param0=drop_weibull,HR_fun=HRf,
ratio=RR)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.