simu.trial: Simulate Survival Trial Data

Description Usage Arguments Details Value References See Also Examples

View source: R/oxy-simu.trial.R View source: R/simu.trial.R

Description

simu.trial simulates survival data allowing flexible input of design parameters. It supports both event-driven design and fixed study duration design.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
simu.trial(
  type = c("event", "time"),
  trial_param,
  bsl_dist = c("weibull", "loglogistic"),
  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,
  HR_fun,
  ratio,
  upInt = 100,
  summary = TRUE
)

Arguments

type

indicates whether event-driven trial ("event) or fixed study duration trial ("time"), Option: c("event", "time")

trial_param

a vector of length 3 with components for required subject size, enrollment time and required number of events ("event" type trial)/follow-up time ("time" type trial)

bsl_dist

indicates the survival distribution for control group, option: c("weibull", "loglogistic")

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, ratio=2 if 2:1 allocation is used.

upInt

a value indicating the upper bound used in the uniroot function. See details. Default: 100

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 λ(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.

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 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.

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

uniroot

Examples

 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)

nphPower documentation built on Dec. 1, 2021, 5:06 p.m.