0

I'm trying to generate a few simulated survival datasets. I've chosen the simsurv function as it allows me to generate time varying coefficients (and hence non-proportional hazards). However, how do I go about defining different censor rates (10%, 30%...etc) for different datasets?

Edward
  • 10,360
  • 2
  • 11
  • 26
Kay
  • 1
  • Hi can you please provide code that you already tried. and example Data – user12256545 May 01 '20 at 23:09
  • I'm guessing it's not possible to get exactly 10%, 30% censoring since the function simulates the data. However, you can adjust the `maxt` argument (maximum event time) to increase or decrease the proportion of data that are censored since any simulated event times greater than this value will be truncated and the status will be set to 0, indicating a _censored_ survival time. – Edward May 01 '20 at 23:18
  • @Edward Thanks, that makes sense. Is there a way to simulate datapoints that are lost to follow up before the end of the study (before maxt), and thus be similarly right censored? e.g. For maxt = '5', eventtime = '1.7', status ='0' – Kay May 03 '20 at 16:29
  • @user12256545, here is my code: library("simsurv") N <- 1000 covs <- data.frame(id = 1:N, trt = rbinom(N, 1, 0.5)) simdat <- simsurv(dist = "weibull", lambdas = 0.1, gammas = 1.5, betas = c(trt = -0.5), x = covs, tde = c(trt = 0.15), tdefunction = "log", maxt = 5) simdat <- merge(simdat, covs) – Kay May 03 '20 at 16:31

0 Answers0