Title: | Simulation of Simple and Complex Survival Data |
---|---|
Description: | Simulation of simple and complex survival data including recurrent and multiple events and competing risks. See Moriña D, Navarro A. (2014) <doi:10.18637/jss.v059.i02> and Moriña D, Navarro A. (2017) <doi:10.1080/03610918.2016.1175621>. |
Authors: | David Moriña Soler [aut, cre] , Albert Navarro [aut] |
Maintainer: | David Moriña Soler <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.1.8 |
Built: | 2024-11-23 04:47:10 UTC |
Source: | https://github.com/cran/survsim |
Simulation of cohorts in a context of simple and complex survival analysis, multiple events and recurrent events including several covariates, individual heterogeneity and periods at risk before and after the initial time of follow-up.
Distribution | Survival function | Density function | Parametrization |
Weibull | |
|
|
Log-normal | |
|
|
Log-logistic | ) |
|
|
Distribution | Time |
Weibull |
|
Log-normal |
|
Log-logistic |
|
Where is the standard normal cumulative distribution.
In order to simulate censored survival data, two survival distributions are required, one for the uncensored survival times that would be observed if the follow-up had been sufficiently long to reach the event and another representing the censoring mechanism. The uncensored survival distribution, , for
subjects, could be generated to depend on a set of covariates with a specified relationship with survival, which represents the true prognostic importance of each covariate (Burton, 2006). The package allows to simulate times by means of using Weibull (and exponential as a particular case), log-normal and log-logistic distributions, as such is showed in previous table.
To induce individual heterogeneity or within-subject correlation we generate
, a random effect covariate that follows a particular distribution (Uniform or Normal).
When , for all subjects, we are in the case of individual homogeneity and the survival times are completely specified by the covariates.
Random non-informative right censoring,
, can be generated in a similar manner to the uncensored survival times,
, by assuming a particular distribution for the censoring times (previous table), but without including any covariates nor individual heterogenity.
The observation times,
, incorporating both events and censored observations are calculated for each case by combining the uncensored survival times,
, and the censoring times,
. If the uncensored survival time for an observation is less than or equal to the censored time, then the event is considered to be observed and the observation time equals the uncensored survival time, otherwise the event is considered censored and the observation time equals the censored time. In other words, once simulated
and
, we can define
as the obervation time with
an indicator of non-censoring, i.e.
.
While all
start at 0, the package allows create dynamic cohorts. We can generate entry times higher than 0 adding a
value corresponding with an uniform distribution in
. We can also simulate subjects at risk before of the initial time of follow-up
, by including an uniform distribution for
between
for a fixed percentage of subjects. Then:
where follows a uniform distribution in
if entry time is 0 or more and
is uniform distributed in
if entry time is less than 0.
Therefore,
represents the initial point of the episode,
the endpoint and
is the lenght. Note that
can be higher than
, and in this case
will be set at
and
. The observations corresponding to the subjects at risk before of the initial time of follow-up have
negative, then the initial point of the episode will be set at 0.
may also be negative, in this case this episode will not be included in the simulated data, as long as this episode won't be observed in practice.
Package: | survsim |
Type: | Package |
Version: | 1.1.8 |
Date: | 2021-12-13 |
License: | GPL version 2 or newer |
LazyLoad: | yes |
The package provide a tool for simulation of cohorts in a simple single-event context through the function simple.surv.sim
, in a recurrent event context with the function rec.ev.sim
, in a multiple event context with the function mult.ev.sim
and in a competing risks context with the function crisk.sim
, and it also allows the user to generate aggregated data from the simulated cohort, by means of the function accum
.
David Moriña, (Universitat de Barcelona) and Albert Navarro (Universitat Autònoma de Barcelona)
Maintainer: David Moriña Soler <[email protected]>
Kelly PJ, Lim LL. Survival analysis for recurrent event data: an application to childhood infectious diseases. Stat Med 2000 Jan 15;19(1):13-33.
Bender R, Augustin T, Blettner M. Generating survival times to simulate Cox proportional hazards models. Stat Med 2005 Jun 15;24(11):1713-1723.
Metcalfe C, Thompson SG. The importance of varying the event generation process in simulation studies of statistical methods for recurrent events. Stat Med 2006 Jan 15;25(1):165-179.
Burton A, Altman DG, Royston P, Holder RL. The design of simulation studies in medical statistics. Stat Med 2006 Dec 30;25(24):4279-4292.
Beyersmann J, Latouche A, Buchholz A, Schumacher M. Simulating competing risks data in survival analysis. Stat Med 2009 Jan 5;28(1):956-971.
Reis RJ, Utzet M, La Rocca PF, Nedel FB, Martin M, Navarro A. Previous sick leaves as predictor of subsequent ones. Int Arch Occup Environ Health 2011 Jun;84(5):491-499.
Navarro A, Moriña D, Reis R, Nedel FB, Martin M, Alvarado S. Hazard functions to describe patterns of new and recurrent sick leave episodes for different diagnoses. Scand J Work Environ Health 2012 Jan 27.
Moriña D, Navarro A. The R package survsim for the simulation of simple and complex survival data. Journal of Statistical Software 2014 Jul; 59(2):1-20.
Aggregate the observed number of events suffered by a subject, the time of follow-up, the duration of all the observed episodes and the real number of events suffered in all subject history.
accum(data)
accum(data)
data |
An object of class |
The output contains z
and real.ep.accum
because they can be interesting when analyzing several aspects as missing data or individual heterogeneity, although those variables cannot be observed in a real cohort.
An object of class sim.ev.agg.data
. It is a data frame with a row for each subject in data
, and the following columns
nid |
an |
old |
real value indicating the time that the individual was at risk before the beginning of the follow-up. |
risk.bef |
|
z |
individual heterogeneity, generated according to the specified distribution. |
x |
value of each covariate randomly generated for each subject in the cohort. |
obs.ep.accum |
aggregated number of episodes suffered by an individual since the beginning of subject's follow-up time. |
real.ep.accum |
aggregated number of episodes suffered by an individual from the beginning of subject's history. |
time.accum |
global time of follow-up for each individual. |
long.accum |
global time not at risk within the follow-up time, corresponding to the sum of times between the end of an event and the beginning of the next. |
David Moriña, Universitat de Barcelona and Albert Navarro, Universitat Autònoma de Barcelona
Kelly PJ, Lim LL. Survival analysis for recurrent event data: an application to childhood infectious diseases. Stat Med 2000 Jan 15;19(1):13-33.
Bender R, Augustin T, Blettner M. Generating survival times to simulate Cox proportional hazards models. Stat Med 2005 Jun 15;24(11):1713-1723.
Metcalfe C, Thompson SG. The importance of varying the event generation process in simulation studies of statistical methods for recurrent events. Stat Med 2006 Jan 15;25(1):165-179.
Reis RJ, Utzet M, La Rocca PF, Nedel FB, Martin M, Navarro A. Previous sick leaves as predictor of subsequent ones. Int Arch Occup Environ Health 2011 Jun;84(5):491-499.
Navarro A, Moriña D, Reis R, Nedel FB, Martin M, Alvarado S. Hazard functions to describe patterns of new and recurrent sick leave episodes for different diagnoses. Scand J Work Environ Health 2012 Jan 27.
Moriña D, Navarro A. The R package survsim for the simulation of simple and complex survival data. Journal of Statistical Software 2014 Jul; 59(2):1-20.
rec.ev.sim
, mult.ev.sim
, crisk.sim
, survsim
, simple.surv.sim
### A cohort with 500 subjects, with a maximum follow-up time of 1825 days and ### just a covariate, following a Bernoulli distribution, and a corresponding ### beta of -0.4, -0.5, -0.6 and -0.7 for each episode, in a context of recurrent ### events. sim.data <- rec.ev.sim(n=500, foltime=1825, dist.ev=c('lnorm','llogistic', 'weibull', 'weibull'),anc.ev=c(1.498, 0.924, 0.923, 1.051),beta0.ev=c(7.195, 6.583, 6.678, 6.430) ,,anc.cens=c(1.272, 1.218, 1.341, 1.484),beta0.cens=c(7.315, 6.975, 6.712, 6.399), z=list(c("unif",0.8,1.2)),beta=list(c(-0.4,-0.5,-0.6,-0.7)), x=list(c("bern", 0.5)), lambda=c(2.18,2.33,2.40,3.46),priskb=0.5,max.old=730) ### Aggregated data accum.data <- accum(sim.data) head(accum.data)
### A cohort with 500 subjects, with a maximum follow-up time of 1825 days and ### just a covariate, following a Bernoulli distribution, and a corresponding ### beta of -0.4, -0.5, -0.6 and -0.7 for each episode, in a context of recurrent ### events. sim.data <- rec.ev.sim(n=500, foltime=1825, dist.ev=c('lnorm','llogistic', 'weibull', 'weibull'),anc.ev=c(1.498, 0.924, 0.923, 1.051),beta0.ev=c(7.195, 6.583, 6.678, 6.430) ,,anc.cens=c(1.272, 1.218, 1.341, 1.484),beta0.cens=c(7.315, 6.975, 6.712, 6.399), z=list(c("unif",0.8,1.2)),beta=list(c(-0.4,-0.5,-0.6,-0.7)), x=list(c("bern", 0.5)), lambda=c(2.18,2.33,2.40,3.46),priskb=0.5,max.old=730) ### Aggregated data accum.data <- accum(sim.data) head(accum.data)
Simulation of cohorts in a context of competing risks survival analysis including several covariates, individual heterogeneity and periods at risk prior and after the start of follow-up.
Competing risks analysis considers time-to-first-event and the event type, possibly subject to right censoring (Beyersmann et al., 2009)
crisk.sim(n, foltime, dist.ev, anc.ev, beta0.ev, dist.cens="weibull", anc.cens, beta0.cens, z=NULL, beta=NA, x=NA, nsit)
crisk.sim(n, foltime, dist.ev, anc.ev, beta0.ev, dist.cens="weibull", anc.cens, beta0.cens, z=NULL, beta=NA, x=NA, nsit)
n |
integer value indicating the desired size of the cohort to be simulated. |
foltime |
real number that indicates the maximum time of follow-up of the simulated cohort. |
dist.ev |
vector of arbitrary size indicating the time to event distributions, with possible values |
anc.ev |
vector of arbitrary size of real components containing the ancillary parameters for the time to event distributions. |
beta0.ev |
vector of arbitrary size of real components containing the |
dist.cens |
string indicating the time to censoring distributions, with possible values |
anc.cens |
real number containing the ancillary parameter for the time to censoring distribution or the maximum in case of uniform distributed time to censoring. |
beta0.cens |
real number containing the |
z |
list of vectors with three elements containing information relative to a random effect used in order to introduce individual heterogeneity. Each vector in the list refers to a possible competing risk, so the number of vectors must be equal to |
beta |
list of vectors indicating the effect of the corresponding covariate. The number of vectors in |
x |
list of vectors indicating the distribution and parameters of any covariate that the user needs to introduce in the simulated cohort. The possible distributions are |
nsit |
Number of different events that a subject can suffer. It must match the number of distributions specified in |
In order to get the function to work properly, the length of the vectors containing the parameters of the time to event and the number of distributions indicated in the parameter dist.ev
must be the same.
An object of class mult.ev.data.sim
. It is a data frame containing the events suffered by the corresponding subjects. The columns of this data frame are detailed below
nid |
an integer number that identifies the subject. |
cause |
cause of the event corresponding to the follow-up time of the individual. |
time |
time until the corresponding event happens (or time to subject drop-out). |
status |
logical value indicating if the corresponding event has been suffered or not. |
start |
time at which the follow-up time begins for each event. |
stop |
time at which the follow-up time ends for each event. |
z |
Individual heterogeneity generated according to the specified distribution. |
x |
value of each covariate randomly generated for each subject in the cohort. |
David Moriña, Universitat de Barcelona and Albert Navarro, Universitat Autònoma de Barcelona
Beyersmann J, Latouche A, Buchholz A, Schumacher M. Simulating competing risks data in survival analysis. Stat Med 2009 Jan 5;28(1):956-971.
survsim-package
, accum
, rec.ev.sim
, mult.ev.sim
, simple.surv.sim
### A cohort with 50 subjects, with a maximum follow-up time of 100 days and two ### covariates, following Bernoulli distributions, and a corresponding beta of ### 0.1698695 and 0.0007010932 for each event for the first covariate and a ### corresponding beta of 0.3735146 and 0.5591244 for each event for the ### second covariate. Notice that the time to censorship is assumed to follow a ### log-normal distribution. sim.data <- crisk.sim(n=50, foltime=100, dist.ev=c("lnorm","lnorm"), anc.ev=c(1.479687, 0.5268302),beta0.ev=c(3.80342, 2.535374),dist.cens="lnorm", anc.cens=1.242733,beta0.cens=5.421748,z=list(c("unif", 0.8,1.2), c("unif", 0.9, 1.5)), beta=list(c(0.1698695,0.0007010932),c(0.3735146,0.5591244)), x=list(c("bern", 0.381), c("bern", 0.564)), nsit=2) summary(sim.data)
### A cohort with 50 subjects, with a maximum follow-up time of 100 days and two ### covariates, following Bernoulli distributions, and a corresponding beta of ### 0.1698695 and 0.0007010932 for each event for the first covariate and a ### corresponding beta of 0.3735146 and 0.5591244 for each event for the ### second covariate. Notice that the time to censorship is assumed to follow a ### log-normal distribution. sim.data <- crisk.sim(n=50, foltime=100, dist.ev=c("lnorm","lnorm"), anc.ev=c(1.479687, 0.5268302),beta0.ev=c(3.80342, 2.535374),dist.cens="lnorm", anc.cens=1.242733,beta0.cens=5.421748,z=list(c("unif", 0.8,1.2), c("unif", 0.9, 1.5)), beta=list(c(0.1698695,0.0007010932),c(0.3735146,0.5591244)), x=list(c("bern", 0.381), c("bern", 0.564)), nsit=2) summary(sim.data)
Simulation of cohorts in a context of multiple event survival analysis including several covariates, individual heterogeneity and periods at risk prior and after the start of follow-up.
Multiple event data occurs when each subject can have more than one event of entirely different natures (Kelly, 2000). Examples of this type of event are the occurrence of tumours at different sites in the body or multiple sequalae after a surgery.
We can obtain the observation time of the -th event in the
-th subject,
, in the same manner that we can simulate
simple independent survival data. Notice that, in multiple-type events,
and
are mutually independent and, furthermore, the failure in each event is independent of the others (within each subject all
are independents for all
).
mult.ev.sim(n, foltime, dist.ev, anc.ev, beta0.ev, dist.cens="weibull", anc.cens, beta0.cens, z=NULL, beta=NA, x=NA, nsit)
mult.ev.sim(n, foltime, dist.ev, anc.ev, beta0.ev, dist.cens="weibull", anc.cens, beta0.cens, z=NULL, beta=NA, x=NA, nsit)
n |
integer value indicating the desired size of the cohort to be simulated. |
foltime |
real number that indicates the maximum time of follow-up of the simulated cohort. |
dist.ev |
vector of arbitrary size indicating the time to event distributions, with possible values |
anc.ev |
vector of arbitrary size of real components containing the ancillary parameters for the time to event distributions. |
beta0.ev |
vector of arbitrary size of real components containing the |
dist.cens |
string indicating the time to censoring distributions, with possible values |
anc.cens |
real number containing the ancillary parameter for the time to censoring distribution or the maximum in case of uniform distributed time to censoring. |
beta0.cens |
real number containing the |
z |
list of vectors with three elements containing information relative to a random effect used in order to introduce individual heterogeneity. Each vector in the list refers to a possible event, so the number of vectors must be equal to |
beta |
list of vectors indicating the effect of the corresponding covariate. The number of vectors in |
x |
list of vectors indicating the distribution and parameters of any covariate that the user needs to introduce in the simulated cohort. The possible distributions are |
nsit |
Number of different events that a subject can suffer. It must match the number of distributions specified in |
In order to get the function to work properly, the length of the vectors containing the parameters of the time to event and the number of distributions indicated in the parameter dist.ev
must be the same.
An object of class mult.ev.data.sim
. It is a data frame containing the events suffered by the corresponding subjects. The columns of this data frame are detailed below
nid |
an integer number that identifies the subject. |
ev.num |
number of the event corresponding to the follow-up time of the individual. |
time |
time until the corresponding event happens (or time to subject drop-out). |
status |
logical value indicating if the corresponding event has been suffered or not. |
start |
time at which the follow-up time begins for each event. |
stop |
time at which the follow-up time ends for each event. |
z |
Individual heterogeneity generated according to the specified distribution. |
x |
value of each covariate randomly generated for each subject in the cohort. |
David Moriña, Universitat de Barcelona and Albert Navarro, Universitat Autònoma de Barcelona
Kelly PJ, Lim LL. Survival analysis for recurrent event data: an application to childhood infectious diseases. Stat Med 2000 Jan 15;19(1):13-33.
Bender R, Augustin T, Blettner M. Generating survival times to simulate Cox proportional hazards models. Stat Med 2005 Jun 15;24(11):1713-1723.
Metcalfe C, Thompson SG. The importance of varying the event generation process in simulation studies of statistical methods for recurrent events. Stat Med 2006 Jan 15;25(1):165-179.
Moriña D, Navarro A. The R package survsim for the simulation of simple and complex survival data. Journal of Statistical Software 2014 Jul; 59(2):1-20.
survsim-package
, accum
, rec.ev.sim
, crisk.sim
, simple.surv.sim
### A cohort with 1000 subjects, with a maximum follow-up time of 3600 days and two ### covariates, following a Bernoulli and uniform distribution respectively, and a ### corresponding beta of -0.4, -0.5, -0.6 and -0.7 for each event for the first ### covariate and a corresponding beta of 0, 0, 0 and 1 for each event for the ### second covariate. Notice that the time to censorship is assumed to follow a ### Weibull distribution, as no other distribution is stated and random effect is ### the same for all events. sim.data <- mult.ev.sim(n=1000, foltime=3600, dist.ev=c('llogistic','weibull', 'weibull','weibull'),anc.ev=c(0.69978200185280, 0.79691659193027, 0.82218416457321, 0.85817155198598),beta0.ev=c(5.84298525742252, 5.94362650803287, 5.78182528904637, 5.46865223339755),,anc.cens=1.17783687569519, beta0.cens=7.39773677281100,z=list(c("unif", 0.8,1.2)), beta=list(c(-0.4,-0.5,-0.6,-0.7), c(0,0,0,1)), x=list(c("bern", 0.5), c("unif", 0.7, 1.3)), nsit=4) summary(sim.data)
### A cohort with 1000 subjects, with a maximum follow-up time of 3600 days and two ### covariates, following a Bernoulli and uniform distribution respectively, and a ### corresponding beta of -0.4, -0.5, -0.6 and -0.7 for each event for the first ### covariate and a corresponding beta of 0, 0, 0 and 1 for each event for the ### second covariate. Notice that the time to censorship is assumed to follow a ### Weibull distribution, as no other distribution is stated and random effect is ### the same for all events. sim.data <- mult.ev.sim(n=1000, foltime=3600, dist.ev=c('llogistic','weibull', 'weibull','weibull'),anc.ev=c(0.69978200185280, 0.79691659193027, 0.82218416457321, 0.85817155198598),beta0.ev=c(5.84298525742252, 5.94362650803287, 5.78182528904637, 5.46865223339755),,anc.cens=1.17783687569519, beta0.cens=7.39773677281100,z=list(c("unif", 0.8,1.2)), beta=list(c(-0.4,-0.5,-0.6,-0.7), c(0,0,0,1)), x=list(c("bern", 0.5), c("unif", 0.7, 1.3)), nsit=4) summary(sim.data)
Simulation of cohorts in a context of recurrent event survival analysis including several covariates, individual heterogeneity and periods at risk before and after the initial time of follow-up.
Recurrent event data is a type of multiple event where the subject can experience repeated occurences of the same type (Kelly, 2000), for example repeated asthma attacks or sick leave episodes. In practice, the hazard of an recurrent event can vary depending on the number of previous occurrences, in terms of shape and intensity (Reis, 2011; Navarro, 2012). However, simulations based on a mixture of distributions with different baseline hazard rates are quite rare (Bender, 2005; Metcalfe, 2006).
In a recurrent data context, each subject can present different number of episodes. We talk of episodes (or occurrences) rather than events since each occurrence is a new episode of the same event. This package supposes that there exists one different and independent distribution depending on
, the number of episode at risk. The simulating process for each
is the same than for the multiple events situation (see
mult.ev.sim
), but in this case, obviously, a subject cannot be at risk for the -th episode if he/she hadn't had the
-th.
rec.ev.sim(n, foltime, dist.ev, anc.ev, beta0.ev, dist.cens=rep("weibull", length(beta0.cens)), anc.cens, beta0.cens, z=NULL, beta=NA, x=NA, lambda=NA, max.ep=Inf, priskb=0, max.old=0)
rec.ev.sim(n, foltime, dist.ev, anc.ev, beta0.ev, dist.cens=rep("weibull", length(beta0.cens)), anc.cens, beta0.cens, z=NULL, beta=NA, x=NA, lambda=NA, max.ep=Inf, priskb=0, max.old=0)
n |
integer value indicating the desired size of the cohort to be simulated. |
foltime |
real number that indicates the maximum time of follow-up of the simulated cohort. |
dist.ev |
vector of arbitrary size indicating the time to event distributions, with possible values |
anc.ev |
vector of arbitrary size of real components containing the ancillary parameters for the time to event distributions. |
beta0.ev |
vector of arbitrary size of real components containing the |
dist.cens |
string indicating the time to censoring distributions, with possible values |
anc.cens |
real number containing the ancillary parameter for the time to censoring distribution or the maximum in case of uniform distributed time to censoring. |
beta0.cens |
real number containing the |
z |
list of vectors with three elements containing information relative to a random effect used in order to introduce individual heterogeneity. Each vector in the list refers to a possible episode, so the number of vectors must be equal to |
beta |
list of vectors indicating the effect of the corresponding covariate. The number of vectors in |
x |
list of vectors indicating the distribution and parameters of any covariate that the user need to introduce in the simulated cohort. The possible distributions are |
lambda |
real number indicating the mean duration of each event or discontinous risk time, assumed to follow a zero-truncated Poisson distribution. Its default value is |
max.ep |
integer value that matches the maximum permitted number of episodes per subject. Its default value is |
priskb |
proportion of subjects at risk prior to the start of follow-up, defaults to 0. |
max.old |
maximum time at risk prior to the start of follow-up. |
In order to get the function to work properly, the length of the vectors containing the parameters of the time to event and time to censure distributions and the number of distributions indicated in the parameter dist
must be the same. Finally, priskb
and max.old
must be positive numbers, with priskb
being between 0 and 1. Notice that large values of max.old
can result in the routine taking a long time to simulate a cohort with the specified size.
An object of class rec.ev.data.sim
. It is a data frame containing the episodes suffered by the corresponding subjects. The columns of the data frame are detailed below
nid |
an integer number that identifies the subject. |
real.episode |
number of the episode corresponding to the real history of the individual. |
obs.episode |
number of the episode corresponding to the follow-up time of the individual. |
time |
time until the corresponding event happens (or time to subject drop-out), regarding the beginning of the follow-up time. |
status |
logical value indicating if the episode corresponds to an event or a drop-out. |
start |
time at which an episode starts, taking the beginning of follow-up as the origin of the time scale. |
stop |
time at which an episode ends, taking the beginning of follow-up as the origin of the time scale. |
time2 |
time until the corresponding event happens (or time to subject drop-out), in calendar time. |
start2 |
time at which an episode starts, where the time scale is calendar time. |
stop2 |
time at which an episode ends, where the time scale is calendar time. |
old |
real value indicating the time that the individual was at risk before the beginning of follow-up. |
risk.bef |
factor that indicates if an individual was at risk before the beginning of follow-up or not. |
long |
time not at risk immediately after an episode. |
z |
Individual heterogeneity generated according to the specified distribution. |
x |
value of each covariate randomly generated for each subject in the cohort. |
David Moriña, Universitat de Barcelona and Albert Navarro, Universitat Autònoma de Barcelona
Kelly PJ, Lim LL. Survival analysis for recurrent event data: an application to childhood infectious diseases. Stat Med 2000 Jan 15;19(1):13-33.
Bender R, Augustin T, Blettner M. Generating survival times to simulate Cox proportional hazards models. Stat Med 2005 Jun 15;24(11):1713-1723.
Metcalfe C, Thompson SG. The importance of varying the event generation process in simulation studies of statistical methods for recurrent events. Stat Med 2006 Jan 15;25(1):165-179.
Reis RJ, Utzet M, La Rocca PF, Nedel FB, Martin M, Navarro A. Previous sick leaves as predictor of subsequent ones. Int Arch Occup Environ Health 2011 Jun;84(5):491-499.
Navarro A, Moriña D, Reis R, Nedel FB, Martin M, Alvarado S. Hazard functions to describe patterns of new and recurrent sick leave episodes for different diagnoses. Scand J Work Environ Health 2012 Jan 27.
Moriña D, Navarro A. The R package survsim for the simulation of simple and complex survival data. Journal of Statistical Software 2014 Jul; 59(2):1-20.
survsim-package
, accum
, mult.ev.sim
, simple.surv.sim
, crisk.sim
### A cohort with 500 subjects, with a maximum follow-up time of 1825 days and ### just a covariate, following a Bernoulli distribution, and a corresponding ### beta of -0.4, -0.5, -0.6 and -0.7 for each episode. Note that random effect is ### the same for all events. sim.data <- rec.ev.sim(n=500, foltime=1825, dist.ev=c('lnorm','llogistic', 'weibull','weibull'),anc.ev=c(1.498, 0.924, 0.923, 1.051),beta0.ev=c(7.195, 6.583, 6.678, 6.430),,anc.cens=c(1.272, 1.218, 1.341, 1.484), beta0.cens=c(7.315, 6.975, 6.712, 6.399), z=list(c("unif", 0.8,1.2)), beta=list(c(-0.4,-0.5,-0.6,-0.7)), x=list(c("bern", 0.5)), lambda=c(2.18,2.33,2.40,3.46), priskb=0.5, max.old=730) summary(sim.data)
### A cohort with 500 subjects, with a maximum follow-up time of 1825 days and ### just a covariate, following a Bernoulli distribution, and a corresponding ### beta of -0.4, -0.5, -0.6 and -0.7 for each episode. Note that random effect is ### the same for all events. sim.data <- rec.ev.sim(n=500, foltime=1825, dist.ev=c('lnorm','llogistic', 'weibull','weibull'),anc.ev=c(1.498, 0.924, 0.923, 1.051),beta0.ev=c(7.195, 6.583, 6.678, 6.430),,anc.cens=c(1.272, 1.218, 1.341, 1.484), beta0.cens=c(7.315, 6.975, 6.712, 6.399), z=list(c("unif", 0.8,1.2)), beta=list(c(-0.4,-0.5,-0.6,-0.7)), x=list(c("bern", 0.5)), lambda=c(2.18,2.33,2.40,3.46), priskb=0.5, max.old=730) summary(sim.data)
Simulation of cohorts in a context of standard survival analysis including several covariates and individual heterogeneity.
simple.surv.sim(n, foltime, dist.ev, anc.ev, beta0.ev, dist.cens="weibull", anc.cens, beta0.cens, z=NULL, beta=NA, x=NA)
simple.surv.sim(n, foltime, dist.ev, anc.ev, beta0.ev, dist.cens="weibull", anc.cens, beta0.cens, z=NULL, beta=NA, x=NA)
n |
integer value indicating the desired size of the cohort to be simulated. |
foltime |
real number that indicates the maximum time of follow-up of the simulated cohort. |
dist.ev |
time to event distributions, with possible values |
anc.ev |
ancillary parameter for the time to event distribution. |
beta0.ev |
|
dist.cens |
string indicating the time to censoring distributions, with possible values |
anc.cens |
real number containing the ancillary parameter for the time to censoring distribution or the maximum in case of uniform distributed time to censoring. |
beta0.cens |
real number containing the |
z |
vector with three elements that contains information relative to a random effect used in order to introduce individual heterogeneity. The first element indicates the distribution: |
beta |
list of elements indicating the effect of the corresponding covariate. The number of vectors in |
x |
list of vectors indicating the distribution and parameters of any covariate that the user needs to introduce in the simulated cohort. The possible distributions are |
An object of class simple.surv.sim
. It is a data frame containing the events suffered by the corresponding subjects. The columns of this data frame are detailed below
nid |
an integer number that identifies the subject. |
status |
logical value indicating if the corresponding event has been suffered or not. |
start |
time at which the follow-up time begins for each event. |
stop |
time at which the follow-up time ends for each event. |
z |
Individual heterogeneity generated according to the specified distribution. |
x |
value of each covariate randomly generated for each subject in the cohort. |
David Moriña, Universitat de Barcelona and Albert Navarro, Universitat Autònoma de Barcelona
Kelly PJ, Lim LL. Survival analysis for recurrent event data: an application to childhood infectious diseases. Stat Med 2000 Jan 15;19(1):13-33.
Bender R, Augustin T, Blettner M. Generating survival times to simulate Cox proportional hazards models. Stat Med 2005 Jun 15;24(11):1713-1723.
Moriña D, Navarro A. The R package survsim for the simulation of simple and complex survival data. Journal of Statistical Software 2014 Jul; 59(2):1-20.
survsim-package
, accum
, rec.ev.sim
, mult.ev.sim
, crisk.sim
### A cohort with 1000 subjects, with a maximum follow-up time of 3600 days and two ### covariates, following a Bernoulli and uniform distribution respectively, and a ### corresponding beta of -0.4 for the first covariate and a corresponding beta of 0 ### for the second covariate. Notice that the time to censorship is assumed to ### follow a Weibull distribution, as no other distribution is stated. sim.data <- simple.surv.sim(n=1000, foltime=3600, dist.ev=c('llogistic'), anc.ev=c(0.69978200185280),beta0.ev=c(5.84298525742252),,anc.cens=1.17783687569519, beta0.cens=7.39773677281100,z=list(c("unif", 0.8, 1.2)), beta=list(c(-0.4), c(0)), x=list(c("bern", 0.5), c("unif", 0.7, 1.3))) summary(sim.data)
### A cohort with 1000 subjects, with a maximum follow-up time of 3600 days and two ### covariates, following a Bernoulli and uniform distribution respectively, and a ### corresponding beta of -0.4 for the first covariate and a corresponding beta of 0 ### for the second covariate. Notice that the time to censorship is assumed to ### follow a Weibull distribution, as no other distribution is stated. sim.data <- simple.surv.sim(n=1000, foltime=3600, dist.ev=c('llogistic'), anc.ev=c(0.69978200185280),beta0.ev=c(5.84298525742252),,anc.cens=1.17783687569519, beta0.cens=7.39773677281100,z=list(c("unif", 0.8, 1.2)), beta=list(c(-0.4), c(0)), x=list(c("bern", 0.5), c("unif", 0.7, 1.3))) summary(sim.data)