simple.surv.sim: Generate a cohort with single-event survival times

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/simple.surv.sim.R

Description

Simulation of cohorts in a context of standard survival analysis including several covariates and individual heterogeneity.

Usage

1
2
simple.surv.sim(n, foltime, dist.ev, anc.ev, beta0.ev, dist.cens="weibull", 
anc.cens, beta0.cens, z=NULL, beta=NA, x=NA)

Arguments

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 weibull for the Weibull distribution, lnorm for the log-normal distribution and llogistic for the log-logistic distribution.

anc.ev

ancillary parameter for the time to event distribution.

beta0.ev

β_0 parameter for the time to event distribution.

dist.cens

string indicating the time to censoring distributions, with possible values weibull for the Weibull distribution, lnorm for the log-normal distribution, llogistic for the log-logistic distribution and unif for the uniform distribution. If no distribution is introduced, the time to censoring is assumed to follow a Weibull distribution.

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 β_0 parameter for the time to censoring distribution or the minimum in case of uniform distributed time to censoring.

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: "unif" states for a uniform distribution, "gamma" states for a gamma distribution, "exp" states for an exponential distribution, "weibull" states for a Weibull distribution and "invgauss" states for an inverse gaussian distribution. The second and third elements indicates the minimum and maximum in the case of a uniform distribution (both must be positive) and the parameters in the case of the rest of distributions. Notice that that just one parameter is needed in the case of exponential distribution. Its default value is NULL, indicating that no individual heterogeneity is introduced.

beta

list of elements indicating the effect of the corresponding covariate. The number of vectors in beta must match the number of covariates. Its default value is NA, indicating that no covariates are included.

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 "normal" for normal distribution, "unif" for uniform distribution and "bern" for Bernoulli distribution. Its default value is NA, indicating that no covariates are included. The number of vectors in x must match the number of vectors in beta. Each vector in x must contain the name of the distribution and the parameter(s), which are: the probability of success in the case of a Bernoulli distribution; the mean and the variance in the case of a normal distribution; and the minimum and maximum in the case of a uniform distribution.

Value

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.

Author(s)

David Moriña, Universitat de Barcelona and Albert Navarro, Universitat Autònoma de Barcelona

References

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.

See Also

survsim-package, accum, rec.ev.sim, mult.ev.sim, crisk.sim

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
### 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)

Example output

Loading required package: eha
Loading required package: survival
Loading required package: statmod

Number of subjects at risk 
----------------------------
  sub.risk
     1000


Number of events 
----------------------------
  num.events
        785


Proportion of subjects with event 
----------------------------
  mean.ep.sub
       0.785


Total time of follow-up 
----------------------------
   foltime
 357199.1


Time of follow-up (median) 
----------------------------
  med.foltime
     221.832


Density of incidence 
----------------------------
   dens.incid
 0.002197654

survsim documentation built on Dec. 14, 2021, 5:09 p.m.