survparamsim {survParamSim} | R Documentation |
Simulation of parametric survival model
Description
The main function(s) to generate predicted survival using a model object
generated with survival::survreg()
function.
Usage
surv_param_sim(
object,
newdata,
n.rep = 1000,
censor.dur = NULL,
coef.var = TRUE,
na.warning = TRUE
)
surv_param_sim_resample(
object,
newdata,
n.rep = 1000,
censor.dur = NULL,
n.resample,
strat.resample = NULL,
coef.var = TRUE,
na.warning = TRUE
)
Arguments
object |
A |
newdata |
A required data frame for simulation that contain covariates in the survival model. It is required even if this is the same as the one used for survival::survreg function. It also has to contain columns for survival information. These can be used
in Subjects with NA for covariates in |
n.rep |
An integer defining numbers of parametric bootstrap runs |
censor.dur |
A two elements vector specifying duration of events censoring. Censoring time will be calculated with uniform distribution between two numbers. No censoring will be applied if NULL is provided. |
coef.var |
Boolean specifying whether parametric bootstrap are performed on survival model coefficients, based on variance-covariance matrix. If FALSE, prediction interval only reflects inherent variability from survival events. |
na.warning |
Boolean specifying whether warning will be shown if
|
n.resample |
Number of subjects for resampled simulations.
If |
strat.resample |
String specifying stratification variable for
resampling. Currently only one variable is allowed. If you need more than one,
create a new variable e.g. by |
Details
surv_param_sim()
returns simulation using the provided subject
in newdata
as it is, while surv_param_sim_resample
perform
simulation based on resampled subjects from the dataset. The latter allows
more flexibility in terms of simulating future trials with different number
of subjects.
Note that with surv_param_sim_resample()
, there is no
automatic safeguard to ensure certain number of subjects in each subgroup
or treatment groups, which may result in inconsistent number of subjects per
simulation or leads to Cox regression instability due to small N. Consider
using stratified resampling in this case.
Currently we have not tested whether this function work for a survreg
model
with stratification variables.
Value
A survparamsim
object that contains the original survreg
class
object, newdata, and a data frame for predicted survival profiles with the
following columns:
-
time: predicted event or censor time
-
event: event status, 0=censored, 1=event
-
rep: ID for parametric bootstrap runs
-
subj: ID for subjects in newdata (currently original ID is not retained and subj is sequentially assigned as 1:nrow(newdata))
Examples
library(survival)
fit.lung <- survreg(Surv(time, status) ~ sex + ph.ecog, data = lung)
object <- fit.lung
n.rep <- 30
newdata <-
tibble::as_tibble(dplyr::select(lung, time, status, sex, ph.ecog)) %>%
tidyr::drop_na()
censor.dur <- c(200, 1100)
sim <- surv_param_sim(object, newdata, n.rep, censor.dur)