simu.trial {nphPower} | R Documentation |
Simulate Survival Trial Data
Description
simu.trial
simulates survival data allowing flexible input
of design parameters. It supports both event-driven design and fixed study duration
design.
Usage
simu.trial(
type = c("event", "time"),
trial_param,
bsl_dist = c("weibull", "loglogistic", "mix-weibull"),
bsl_param,
drop_param0,
drop_param1 = drop_param0,
entry_pdf0 = function(x) {
(1/trial_param[2]) * (x >= 0 & x <= trial_param[2])
},
entry_pdf1 = entry_pdf0,
enrollmentType = NULL,
entryP = list(10000, 1),
HR_fun,
ratio,
cureModel = NULL,
cureRate1 = NULL,
HR_data = NULL,
upInt = 100,
summary = TRUE
)
Arguments
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 weibull or loglogistic survival distribution of control group. A vector of length 3 with shape, rate and cure rate for the mix-weibull distribution. 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. |
enrollmentType |
default value is NULL, indicating a entry time follows specified
distribution. Specify " |
entryP |
if |
HR_fun |
a function describing the hazard ratio function between treatment and control group |
ratio |
allocation ratio between treatment and control group.
For example, |
cureModel |
specifies the cure model. " |
cureRate1 |
specifies the cure rate for the susceptible population in the experimental group if the cure model is |
HR_data |
a matrix consisting of covariates values |
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 |
Details
The loglogistic distribution for the event time has the
survival function S(x)=b^a/(b^a+x^a)
and hazard function
\lambda(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 S(x)=exp(-(xb)^a)
and hazard function \lambda(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 \lambda_1(t)
and \lambda_0(t)
denote the hazard function for treatment and control. It is assumed that
\lambda_1(t)/\lambda_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)\lambda_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.
Value
A list containing the following components
data
: a dataframe (simulated dataset) with columns:
- id
identifier number from 1:n, n is the total sample size
- group
group variable with 1 indicating treatment and 0 indicating control
- aval
observed survival time, the earliest time among event time, drop-out time and end of study time
- cnsr
censoring indicator with 1 indicating censor and 0 indicating event
- cnsr.desc
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
event indicator with 1 indicating event and 0 indicating censor
- entry.time
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
ortime
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. Forevent
type of design, the value is the calendar time of the last event.
References
Bender, R., Augustin, T., & Blettner, M. (2005). Generating survival times to simulate Cox proportional hazards models. Statistics in medicine, 24(11), 1713-1723.
See Also
Weibull
, integrate
, Logistic
, Uniform
, optimize
, uniroot
Examples
# 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)