Fit model with survreg() function

Before running a parametric survival simulation, you need to fit a model to your data using survreg() function of survival package.
In this vignette, we will be using colon dataset available in survival package, where the treatment effect of adjuvant Levamisole+5-FU for colon cancer over placebo is evaluated.

First, we load the data and do some data wrangling.

Generating Kaplan-Meier curves for visually checking the data.
The second plot is looking at how many censoring we have over time.
Looks like we have a fairly uniform censoring between 1800 to 3000 days.

Next we fit a lognormal parametric model for the data.
Here we are using node4 and depth as additional covariates in addition to treatment (rx).
You can see that all of the factor has strong association with the outcome.

Perform simulation

surv_param_sim() is the main function of the package that takes survreg object as described above.
It also require you to supply newdata, which is required even if it is not new - i.e. the same data was used for both survreg() and surv_param_sim().

What it does is: 1. Re-sample all the coefficients in the parametric survival model from variance-covariance matrix for n.rep times. 2. Perform survival time for all subjects in newdata with the corresponding covariates, using one of the resampled coefficients. Also generate censoring time according to censor.dur (if not NULL), and replace the simulated survival time above if censoring time is earlier. 4. Repeat the steps 2. for n.rep times.

After the simulation is performed, you can either extract raw simulation results or further calculate Kaplan-Meier estimates or hazard ratio of treatment effect, as you see when you type sim in the console.

Hazard ratios (HRs)

To calculate prediction intervals of HRs, calc_hr_pi() can be used on the simulated object above. Here I only generated subgroups based on “depth”, since the very small N in (depth: 1 & nodes4: 1) can cause issue with calculating HRs.