With this function previously simulated data (for example simulated by the use of simrec
or simreccomp
)
can be cut to an interim data set.
The simulated data must be in patient time (i.e. time since the patient entered the study),
and must be in the counting process format. Furthermore the dataset must have the variables id
, start
, stop
and status
,
like data simulated by the use of simrec
or simreccomp
.
Then for every individual additionally a recruitment time is generated in study time (i.e. time since start of the study),
which is uniformly distributed on [0, tR]
.
The timing of the interim analysis tI
is set in study time and
data are being cut to all data, that are available at the interim analysis.
For further explanations on study time and patient time see the vignette.
If you only wish to simulate a recruitment time, tI
can be set to tR + fu.max
or something bigger.
simrecint(data, N, tR, tI)
The output is a data.frame consisting of the columns, that were put into, and additionally the following columns:
The recruitment time for each individual (in study time).
The time of the interim analysis tI
(in study time).
The stopping time for each event in study time.
Individuals that are not already recruited at the interim analysis are left out here.
simrec, simreccomp
### Example - see example for simrec
library(simrec)
N <- 10
dist.x <- c("binomial", "normal")
par.x <- list(0.5, c(0, 1))
beta.x <- c(0.3, 0.2)
dist.z <- "gamma"
par.z <- 0.25
dist.rec <- "weibull"
par.rec <- c(1, 2)
fu.min <- 2
fu.max <- 2
cens.prob <- 0.2
simdata <- simrec(
N, fu.min, fu.max, cens.prob, dist.x, par.x, beta.x, dist.z,
par.z, dist.rec, par.rec
)
### Now simulate for each patient a recruitment time in [0,tR=2]
### and cut data to the time of the interim analysis at tI=1:
simdataint <- simrecint(simdata, N = N, tR = 2, tI = 1)
# print(simdataint) # only run for small N!