2
$\begingroup$

I'm trying to identify how the cox proportional hazards model behave with different censoring proportions and sample sizes. (Censoring proportions = 20%, 50%, 70%). For that I need to simulate survival datasets having different censoring proportions using the simsurv package in R. I'm considering weibull distribution, expponential distribution and 2 parameter mixture distribution for the simulations.

To define the censoring I used maxt argument but it does not directly define the censoring proportions. Heres the code that I used.

# Censoring after 5 years
set.seed(1234)
covs <- data.frame(id = 1:100, trt1 = rbinom(100, 8, 0.5), trt2 = rnorm(100,5,1.5))
surv.data <- simsurv(lambdas = 0.1, gammas = 1.5, betas = c(trt1 = -0.5, trt2 = 0.7),
              x = covs, maxt = 5)
surv.data

Is there any other direct way to define the censoring proportion of the simulated data. If not how should I define maxt argument to have the desired censoring proportions?

I also need to include a nominal variable as a covariate for the data having 3 levels with only one level having significant effect on the response. How should I define the true parameter values of the covariate effect in the beta argument for that variable?

$\endgroup$

1 Answer 1

0
$\begingroup$

The maxt argument here specifies the latest time that the simulation will try to estimate; any individuals with estimated event times beyond that will just have a right-censored observation at the maxt value. That's specified so that the algorithm doesn't slow down when estimating very late event times (which in principle could approach infinity).

First, be sure that you choose a maxt value that leads to no more censoring than your lowest desired censoring fraction (20% here).

Your example is a simple "Type I" censoring with all individuals followed up until the event or for a fixed period of time (5 years here) after study entry. In that case, after you simulate with a (possibly much larger) maxt value that provides no more than 20% censoring, examine how the censoring fraction changes as you alter the maximum follow-up time.

For example, if you use 2 years as the maximum follow-up time, what fraction of cases were either right-censored due to the maxt simulation limit or have simulated event times greater than 2 years? Try different maximum follow-up times until you get your desired 20%, 50%, or 70% censoring fractions. The specific time values don't matter, if what you care about is the fraction of cases that have censored observations in this simple type of censoring. The influences of sample size and censoring fractions on model quality will be the same (for any given set of betas).

Things are more complicated if you also have random censoring times, as covered in an earlier question. Then there might need to be more complicated trial-and-error that combines the random censoring model with the maximum follow up.

For the coefficients of the 3-level categorical predictor, recognize that such a predictor is modeled internally with "dummy variables." For example, if the mutually exclusive levels are cov0 (the reference level), cov1 and cov2, then the survival-analysis software would report coefficients for cov1 and cov2 while the baseline hazard would hold if the value was cov0.

So do that yourself when you simulate that predictor. Set up cov1 and cov2 variables, each of which can take on a value of either 0 or 1. Those should both be 0 if the simulated level is cov0; otherwise, set the value to 1 for the corresponding simulated level. If you want only cov2 to have different from baseline survival (after the other predictors like trt1 and trt2 are taken into account), then specify beta as 0 for cov1 and your desired log-hazard ratio for cov2.

$\endgroup$
2
  • $\begingroup$ This is really helpful. Does the type of censoring make an influence on the model quality then? How do I simulate Type III right censored data? $\endgroup$ Jul 31, 2023 at 14:37
  • $\begingroup$ @NipuniOpatha for Type III censoring (random censoring), you would have to use two probability models, one for the survival times (a function of covariate values) and a second (independent of covariates) for the random censoring times. Then you have to use a trial-and-error approach to get the desired censoring fractions, as discussed in an earlier question/answer. The main determinant of model quality is the number of events; I don't know whether the same number of events would lead to different quality as a function of censoring type. $\endgroup$
    – EdM
    Jul 31, 2023 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.