Title: | Simulation of Recurrent Event Data for Non-Constant Baseline Hazard |
---|---|
Description: | Simulation of recurrent event data for non-constant baseline hazard in the total time model with risk-free intervals and possibly a competing event. Possibility to cut the data to an interim data set. Data can be plotted. Details about the method can be found in Jahn-Eimermacher, A. et al. (2015) <doi:10.1186/s12874-015-0005-2>. |
Authors: | Katharina Ingel [aut], Antje Jahn-Eimermacher [aut], Stella Preussler [aut], Federico Marini [aut, cre] |
Maintainer: | Federico Marini <[email protected]> |
License: | GPL-2 |
Version: | 1.0.1 |
Built: | 2024-10-30 05:31:14 UTC |
Source: | https://github.com/federicomarini/simrec |
Simulation of recurrent event data for non-constant baseline hazard (total-time model)
This function allows simulation of recurrent event data following the multiplicative
intensity model described in Andersen and Gill [1] with the baseline hazard being a
function of the total/calendar time. To induce between-subject-heterogeneity a random
effect covariate (frailty term) can be incorporated. Data for individual are generated
according to the intensity process
where defines the covariate vector and
the regression coefficient vector.
denotes the baseline hazard, being a function of the total/calendar
time
, and
the predictable process
that equals one as long as individual
is under observation and at risk for experiencing events.
denotes the frailty variable with
iid with
and
. The parameter
describes the degree of
between-subject-heterogeneity. Data output is in the counting process format.
simrec( N, fu.min, fu.max, cens.prob = 0, dist.x = "binomial", par.x = 0, beta.x = 0, dist.z = "gamma", par.z = 0, dist.rec, par.rec, pfree = 0, dfree = 0 )
simrec( N, fu.min, fu.max, cens.prob = 0, dist.x = "binomial", par.x = 0, beta.x = 0, dist.z = "gamma", par.z = 0, dist.rec, par.rec, pfree = 0, dfree = 0 )
N |
Number of individuals |
fu.min |
Minimum length of follow-up. |
fu.max |
Maximum length of follow-up. Individuals length of follow-up is
generated from a uniform distribution on
|
cens.prob |
Gives the probability of being censored due to loss to follow-up before
|
dist.x |
Distribution of the covariate(s) |
par.x |
Parameters of the covariate distribution(s). For |
beta.x |
Regression coefficient(s) for the covariate(s) |
dist.z |
Distribution of the frailty variable |
par.z |
Parameter |
dist.rec |
Form of the baseline hazard function. Possible values are |
par.rec |
Parameters for the distribution of the event data.
If
where
where
where
.
Then |
pfree |
Probability that after experiencing an event the individual is not at risk
for experiencing further events for a length of |
dfree |
Length of the risk-free interval. Must be in the same time unit as |
Simulation of recurrent event data for non-constant baseline hazard in the total time model with risk-free intervalls and possibly a competing event. The simrec package enables to cut the data to an interim data set, and provides functionality to plot.
Data are simulated by extending the methods proposed by Bender et al [2] to the multiplicative intensity model.
The output is a data.frame consisting of the columns:
id |
An integer number for identification of each individual |
x |
or |
z |
Contains the randomly generated value of the frailty variable |
start |
The start of interval |
stop |
The time of an event or censoring, i.e. the end of interval
|
status |
An indicator of whether an event occured at time |
fu |
Length of follow-up period |
For each individual there are as many lines as it experiences events, plus one line if being censored. The data format corresponds to the counting process format.
Katharina Ingel, Stella Preussler, Antje Jahn-Eimermacher, Federico Marini
Maintainer: Antje Jahn-Eimermacher [email protected]
Katharina Ingel, Stella Preussler, Antje Jahn-Eimermacher. Institute of Medical Biostatistics, Epidemiology and Informatics (IMBEI), University Medical Center of the Johannes Gutenberg-University Mainz, Germany
Andersen P, Gill R (1982): Cox's regression model for counting processes: a large sample study. The Annals of Statistics 10:1100-1120
Bender R, Augustin T, Blettner M (2005): Generating survival times to simulate Cox proportional hazards models. Statistics in Medicine 24:1713-1723
Jahn-Eimermacher A, Ingel K, Ozga AK, Preussler S, Binder H (2015): Simulating recurrent event data with hazard functions defined on a total time scale. BMC Medical Research Methodology 15:16
Useful links:
simreccomp
### Example: ### A sample of 10 individuals N <- 10 ### with a binomially distributed covariate with a regression coefficient ### of beta=0.3, and a standard normally distributed covariate with a ### regression coefficient of beta=0.2, dist.x <- c("binomial", "normal") par.x <- list(0.5, c(0, 1)) beta.x <- c(0.3, 0.2) ### a gamma distributed frailty variable with variance 0.25 dist.z <- "gamma" par.z <- 0.25 ### and a Weibull-shaped baseline hazard with shape parameter lambda=1 ### and scale parameter nu=2. dist.rec <- "weibull" par.rec <- c(1, 2) ### Subjects are to be followed for two years with 20% of the subjects ### being censored according to a uniformly distributed censoring time ### within [0,2] (in years). fu.min <- 2 fu.max <- 2 cens.prob <- 0.2 ### After each event a subject is not at risk for experiencing further events ### for a period of 30 days with a probability of 50%. dfree <- 30 / 365 pfree <- 0.5 simdata <- simrec( N, fu.min, fu.max, cens.prob, dist.x, par.x, beta.x, dist.z, par.z, dist.rec, par.rec, pfree, dfree ) # print(simdata) # only run for small N!
### Example: ### A sample of 10 individuals N <- 10 ### with a binomially distributed covariate with a regression coefficient ### of beta=0.3, and a standard normally distributed covariate with a ### regression coefficient of beta=0.2, dist.x <- c("binomial", "normal") par.x <- list(0.5, c(0, 1)) beta.x <- c(0.3, 0.2) ### a gamma distributed frailty variable with variance 0.25 dist.z <- "gamma" par.z <- 0.25 ### and a Weibull-shaped baseline hazard with shape parameter lambda=1 ### and scale parameter nu=2. dist.rec <- "weibull" par.rec <- c(1, 2) ### Subjects are to be followed for two years with 20% of the subjects ### being censored according to a uniformly distributed censoring time ### within [0,2] (in years). fu.min <- 2 fu.max <- 2 cens.prob <- 0.2 ### After each event a subject is not at risk for experiencing further events ### for a period of 30 days with a probability of 50%. dfree <- 30 / 365 pfree <- 0.5 simdata <- simrec( N, fu.min, fu.max, cens.prob, dist.x, par.x, beta.x, dist.z, par.z, dist.rec, par.rec, pfree, dfree ) # print(simdata) # only run for small N!
This function allows simulation of time-to-event-data that follow a multistate-model
with recurrent events of one type and a competing event. The baseline hazard for the
cause-specific hazards are here functions of the total/calendar time.
To induce between-subject-heterogeneity a random
effect covariate (frailty term) can be incorporated for the recurrent and the competing event.
Data for the recurrent events of the individual are generated
according to the cause-specific hazards
where defines the covariate vector and
the regression coefficient vector.
denotes the baseline hazard, being a function of the total/calendar
time
and
denotes the frailty variables with
iid with
and
. The parameter
describes the degree of
between-subject-heterogeneity for the recurrent event.
Analougously the competing event is generated according to the cause-specific hazard conditionally
on the frailty variable and covariates:
Data output is in the counting process format.
simreccomp( N, fu.min, fu.max, cens.prob = 0, dist.x = "binomial", par.x = 0, beta.xr = 0, beta.xc = 0, dist.zr = "gamma", par.zr = 0, a = NULL, dist.zc = NULL, par.zc = NULL, dist.rec, par.rec, dist.comp, par.comp, pfree = 0, dfree = 0 )
simreccomp( N, fu.min, fu.max, cens.prob = 0, dist.x = "binomial", par.x = 0, beta.xr = 0, beta.xc = 0, dist.zr = "gamma", par.zr = 0, a = NULL, dist.zc = NULL, par.zc = NULL, dist.rec, par.rec, dist.comp, par.comp, pfree = 0, dfree = 0 )
N |
Number of individuals |
fu.min |
Minimum length of follow-up. |
fu.max |
Maximum length of follow-up. Individuals length of follow-up is
generated from a uniform distribution on
|
cens.prob |
Gives the probability of being censored due to loss to follow-up before
|
dist.x |
Distribution of the covariate(s) |
par.x |
Parameters of the covariate distribution(s). For |
beta.xr |
Regression coefficient(s) for the covariate(s) |
beta.xc |
Regression coefficient(s) for the covariate(s) |
dist.zr |
Distribution of the frailty variable |
par.zr |
Parameter |
a |
Alternatively, the frailty distribution for the competing event can be computed through the distribution
of the frailty variable |
dist.zc |
Distribution of the frailty variable |
par.zc |
Parameter |
dist.rec |
Form of the baseline hazard function for the recurrent events.
Possible values are |
par.rec |
Parameters for the distribution of the recurrent event data.
If
where
where
where
.
Then |
dist.comp |
Form of the baseline hazard function for the competing event.
Possible values are |
par.comp |
Parameters for the distribution of the competing event data.
For more details see |
pfree |
Probability that after experiencing an event the individual is not at risk
for experiencing further events for a length of |
dfree |
Length of the risk-free interval. Must be in the same time unit as |
The output is a data.frame consisting of the columns:
id |
An integer number for identification of each individual |
x |
or |
zr |
Contains the randomly generated value of the frailty variable |
zc |
Contains the randomly generated value of the frailty variable |
start |
The start of interval |
stop |
The time of an event or censoring, i.e. the end of interval |
status |
An indicator of whether an event occured at time |
fu |
Length of follow-up period |
For each individual there are as many lines as it experiences events, plus one line if being censored. The data format corresponds to the counting process format.
Katharina Ingel, Stella Preussler, Antje Jahn-Eimermacher. Institute of Medical Biostatistics, Epidemiology and Informatics (IMBEI), University Medical Center of the Johannes Gutenberg-University Mainz, Germany
simrec
### Example: ### A sample of 10 individuals N <- 10 ### with a binomially distributed covariate and a standard normally distributed covariate ### with regression coefficients of beta.xr=0.3 and beta.xr=0.2, respectively, ### for the recurrent events, ### as well as regression coefficients of beta.xc=0.5 and beta.xc=0.25, respectively, ### for the competing event. dist.x <- c("binomial", "normal") par.x <- list(0.5, c(0, 1)) beta.xr <- c(0.3, 0.2) beta.xc <- c(0.5, 0.25) ### a gamma distributed frailty variable for the recurrent event with variance 0.25 ### and for the competing event with variance 0.3, dist.zr <- "gamma" par.zr <- 0.25 dist.zc <- "gamma" par.zc <- 0.3 ### alternatively the frailty variable for the competing event can be computed via a: a <- 0.5 ### Furthermore a Weibull-shaped baseline hazard for the recurrent event with shape parameter ### lambda=1 and scale parameter nu=2, dist.rec <- "weibull" par.rec <- c(1, 2) ### and a Weibull-shaped baseline hazard for the competing event with shape parameter lambda=1 ### and scale parameter nu=2 dist.comp <- "weibull" par.comp <- c(1, 2) ### Subjects are to be followed for two years with 20% of the subjects ### being censored according to a uniformly distributed censoring time ### within [0,2] (in years). fu.min <- 2 fu.max <- 2 cens.prob <- 0.2 ### After each event a subject is not at risk for experiencing further events ### for a period of 30 days with a probability of 50%. dfree <- 30 / 365 pfree <- 0.5 simdata1 <- simreccomp( N = N, fu.min = fu.min, fu.max = fu.max, cens.prob = cens.prob, dist.x = dist.x, par.x = par.x, beta.xr = beta.xr, beta.xc = beta.xc, dist.zr = dist.zr, par.zr = par.zr, a = a, dist.rec = dist.rec, par.rec = par.rec, dist.comp = dist.comp, par.comp = par.comp, pfree = pfree, dfree = dfree ) simdata2 <- simreccomp( N = N, fu.min = fu.min, fu.max = fu.max, cens.prob = cens.prob, dist.x = dist.x, par.x = par.x, beta.xr = beta.xr, beta.xc = beta.xc, dist.zr = dist.zr, par.zr = par.zr, dist.zc = dist.zc, par.zc = par.zc, dist.rec = dist.rec, par.rec = par.rec, dist.comp = dist.comp, par.comp = par.comp, pfree = pfree, dfree = dfree ) simdata1 simdata2
### Example: ### A sample of 10 individuals N <- 10 ### with a binomially distributed covariate and a standard normally distributed covariate ### with regression coefficients of beta.xr=0.3 and beta.xr=0.2, respectively, ### for the recurrent events, ### as well as regression coefficients of beta.xc=0.5 and beta.xc=0.25, respectively, ### for the competing event. dist.x <- c("binomial", "normal") par.x <- list(0.5, c(0, 1)) beta.xr <- c(0.3, 0.2) beta.xc <- c(0.5, 0.25) ### a gamma distributed frailty variable for the recurrent event with variance 0.25 ### and for the competing event with variance 0.3, dist.zr <- "gamma" par.zr <- 0.25 dist.zc <- "gamma" par.zc <- 0.3 ### alternatively the frailty variable for the competing event can be computed via a: a <- 0.5 ### Furthermore a Weibull-shaped baseline hazard for the recurrent event with shape parameter ### lambda=1 and scale parameter nu=2, dist.rec <- "weibull" par.rec <- c(1, 2) ### and a Weibull-shaped baseline hazard for the competing event with shape parameter lambda=1 ### and scale parameter nu=2 dist.comp <- "weibull" par.comp <- c(1, 2) ### Subjects are to be followed for two years with 20% of the subjects ### being censored according to a uniformly distributed censoring time ### within [0,2] (in years). fu.min <- 2 fu.max <- 2 cens.prob <- 0.2 ### After each event a subject is not at risk for experiencing further events ### for a period of 30 days with a probability of 50%. dfree <- 30 / 365 pfree <- 0.5 simdata1 <- simreccomp( N = N, fu.min = fu.min, fu.max = fu.max, cens.prob = cens.prob, dist.x = dist.x, par.x = par.x, beta.xr = beta.xr, beta.xc = beta.xc, dist.zr = dist.zr, par.zr = par.zr, a = a, dist.rec = dist.rec, par.rec = par.rec, dist.comp = dist.comp, par.comp = par.comp, pfree = pfree, dfree = dfree ) simdata2 <- simreccomp( N = N, fu.min = fu.min, fu.max = fu.max, cens.prob = cens.prob, dist.x = dist.x, par.x = par.x, beta.xr = beta.xr, beta.xc = beta.xc, dist.zr = dist.zr, par.zr = par.zr, dist.zc = dist.zc, par.zc = par.zc, dist.rec = dist.rec, par.rec = par.rec, dist.comp = dist.comp, par.comp = par.comp, pfree = pfree, dfree = dfree ) simdata1 simdata2
This function allows plotting of recurrent event data with a competing event.
simreccompPlot( data, id = "id", start = "start", stop = "stop", status = "status" )
simreccompPlot( data, id = "id", start = "start", stop = "stop", status = "status" )
data |
A data set of recurrent event data to be plotted.
The input-data must include columns corresponding to:
|
id |
the name of the |
start |
the name of the |
stop |
the name of the |
status |
the name of the |
The output is a plot of the data with a bullet indicating a recurrent event, an x indicating the competing event and a circle indicating censoring.
Katharina Ingel, Stella Preussler, Antje Jahn-Eimermacher. Institute of Medical Biostatistics, Epidemiology and Informatics (IMBEI), University Medical Center of the Johannes Gutenberg-University Mainz, Germany
simrec, simreccomp, simrecPlot
### Example: ### First simulate a sample of 10 individuals (for more details see the help of \code{simreccomp}) N <- 10 dist.x <- c("binomial", "normal") par.x <- list(0.5, c(0, 1)) beta.xr <- c(0.3, 0.2) beta.xc <- c(0.5, 0.25) dist.zr <- "gamma" par.zr <- 0.25 dist.zc <- "gamma" par.zc <- 0.3 dist.rec <- "weibull" par.rec <- c(1, 2) dist.comp <- "weibull" par.comp <- c(1, 2) fu.min <- 2 fu.max <- 2 cens.prob <- 0.2 dfree <- 30 / 365 pfree <- 0.5 simdata <- simreccomp( N = N, fu.min = fu.min, fu.max = fu.max, cens.prob = cens.prob, dist.x = dist.x, par.x = par.x, beta.xr = beta.xr, beta.xc = beta.xc, dist.zr = dist.zr, par.zr = par.zr, dist.zc = dist.zc, par.zc = par.zc, dist.rec = dist.rec, par.rec = par.rec, dist.comp = dist.comp, par.comp = par.comp, pfree = pfree, dfree = dfree ) simreccompPlot(simdata)
### Example: ### First simulate a sample of 10 individuals (for more details see the help of \code{simreccomp}) N <- 10 dist.x <- c("binomial", "normal") par.x <- list(0.5, c(0, 1)) beta.xr <- c(0.3, 0.2) beta.xc <- c(0.5, 0.25) dist.zr <- "gamma" par.zr <- 0.25 dist.zc <- "gamma" par.zc <- 0.3 dist.rec <- "weibull" par.rec <- c(1, 2) dist.comp <- "weibull" par.comp <- c(1, 2) fu.min <- 2 fu.max <- 2 cens.prob <- 0.2 dfree <- 30 / 365 pfree <- 0.5 simdata <- simreccomp( N = N, fu.min = fu.min, fu.max = fu.max, cens.prob = cens.prob, dist.x = dist.x, par.x = par.x, beta.xr = beta.xr, beta.xc = beta.xc, dist.zr = dist.zr, par.zr = par.zr, dist.zc = dist.zc, par.zc = par.zc, dist.rec = dist.rec, par.rec = par.rec, dist.comp = dist.comp, par.comp = par.comp, pfree = pfree, dfree = dfree ) simreccompPlot(simdata)
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)
simrecint(data, N, tR, tI)
data |
Previously generated data (in patient time), that shall be cut to interim data |
N |
Number of individuals, for which |
tR |
Length of the recruitment period (in study time) |
tI |
Timing of the interim analysis (in study time) |
The output is a data.frame consisting of the columns, that were put into, and additionally the following columns:
rectime |
The recruitment time for each individual (in study time). |
interimtime |
The time of the interim analysis |
stop_study |
The stopping time for each event in study time. |
Individuals that are not already recruited at the interim analysis are left out here.
Katharina Ingel, Stella Preussler, Antje Jahn-Eimermacher. Institute of Medical Biostatistics, Epidemiology and Informatics (IMBEI), University Medical Center of the Johannes Gutenberg-University Mainz, Germany
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!
### 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!
This function allows plotting of recurrent event data.
simrecPlot(data, id = "id", start = "start", stop = "stop", status = "status")
simrecPlot(data, id = "id", start = "start", stop = "stop", status = "status")
data |
A data set of recurrent event data to be plotted.
The input-data must include columns corresponding to:
|
id |
the name of the |
start |
the name of the |
stop |
the name of the |
status |
the name of the |
The output is a plot of the data with a bullet indicating a recurrent event and a circle indicating censoring.
Katharina Ingel, Stella Preussler, Antje Jahn-Eimermacher. Institute of Medical Biostatistics, Epidemiology and Informatics (IMBEI), University Medical Center of the Johannes Gutenberg-University Mainz, Germany
simrec, simreccomp, simreccompPlot
### Example: ### First simulate a sample of 10 individuals (for more details see the help of \code{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 dfree <- 30 / 365 pfree <- 0.5 simdata <- simrec( N, fu.min, fu.max, cens.prob, dist.x, par.x, beta.x, dist.z, par.z, dist.rec, par.rec, pfree, dfree ) simrecPlot(simdata)
### Example: ### First simulate a sample of 10 individuals (for more details see the help of \code{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 dfree <- 30 / 365 pfree <- 0.5 simdata <- simrec( N, fu.min, fu.max, cens.prob, dist.x, par.x, beta.x, dist.z, par.z, dist.rec, par.rec, pfree, dfree ) simrecPlot(simdata)