Learn R Programming

prodlim (version 1.0.5)

SimSurv: Simulating survival data

Description

Censored event times are drawn from user specified conditional distributions given simulated covariates.

Usage

SimSurv(N,
	surv = list(dist="rweibull",
	  args=list(shape=1),
	  baseline=1,
	  link="exp",
	  coef=1,
	  transform=NULL,
	  method="simulation"),
	cens = list(dist="rexp",
	  args=NULL,
	  baseline=1/100,
	  link="exp",
	  max=NULL,
	  type="right",
	  coef=0,
	  transform=NULL,
	  method="transform"),
	cova = list(X1=list("rnorm",mean=0,sd=2),
	  X2=list("rbinom",size=1,prob=.5)),
	verbose=1,
	...)

Arguments

N
Sample size
surv
A list with the following arguments dist{ name of the function to draw the survival distribution} args{ list of extra arguments to `dist'} baseline{ the baseline risk} link{ names of the
cens
A list with the following elements dist{ name of the function to draw the censoring distribution} args{ list of extra arguments to `dist'} baseline{ the baseline risk} link{ names of the
cova
either a matrix with N rows, or a named list to generate the covariates. each entry is a list where the first element is the names of the function used to draw the covariate values and the remaining elements are arguments pass
verbose
Set to FALSE to shut up in simulations
...
used for convenient argument specification, e.g. surv.transform.X2=function(x)x^2 will overwrite a corresponding entry of surv for the transform of the covariate X2

Value

  • A data.frame:
  • timethe right censored event times
  • statusthe survival status
  • Xthe values of the covariate X
  • f.Xthe transformed values of the covariate X
  • timethe uncensored event times
  • Attributes of the data.frame
  • formula
  • a formula to evaluate the generated event history object

Details

Possible distributions to generate covariates:

X.lognorm = list(dist = "rlnorm", meanlog = 2, sdlog = 0.4) X.unif = list(dist = "runif", min = 0, max = 10), X.exp = list(dist = "rexp", rate = 0.4) X.bernoulli = list(dist = "rbinom", size = 1, prob = 0.3) X.binom = list(dist = "rbinom", size = 4, prob = 0.8) X.nbinom = list(dist = "rnbinom", size = 3, mu = 2) X.poisson = list(dist = "rpois", lambda = 1.3)

References

Ralf Bender, Thomas Augustin, and Maria Blettner. Generating survival times to simulate Cox proportional hazards models by Ralf Bender, Thomas Augustin and Maria Blettner, Statistics in Medicine 2005; 24:1713-1723. Stat Med, 25(11):1978-9, 2006.

See Also

prodlim

Examples

Run this code
SimSurv(10)

SurvData=SimSurv(100,cens.baseline=1/10,surv.baseline=2)

Hist(SurvData$time,SurvData$status)

prodlim(Hist(time,status)~1,data=SurvData)

plot(prodlim(Hist(time,status)~1,data=SurvData))

plot(SurvData,atrisk=FALSE,legend=FALSE)

SurvData=SimSurv(100,cens.baseline=1/10,surv.baseline=2,surv.coef=c(-1,-2),
         cova=list( X.exp = list(dist = "rexp", rate = 0.4),
         X.bernoulli = list(dist = "rbinom", size = 1, prob = 0.3)))
SurvData=SimSurv(100,cens.baseline=1/10,surv.baseline=2,surv.coef=c(-1,-2),cens.coef=c(0,1),
          cova=list( X.exp = list(dist = "rexp", rate = 0.4),
          X.bernoulli = list(dist = "rbinom", size = 1, prob = 0.3)))

coxph(Surv(time,status==0)~X.exp+X.bernoulli,data=SurvData)

coxph(Surv(time,status)~X.exp+X.bernoulli,data=SurvData)

Run the code above in your browser using DataLab