Run complete parametric survival analysis for multiple models with multiple distributions

runPSM(
  data,
  time_var,
  event_var,
  weight_var = "",
  model.type = c("Separate", "Common shape", "Independent shape"),
  distr = c("exp", "weibull", "gompertz", "lnorm", "llogis", "gengamma", "gamma",
    "genf"),
  strata_var,
  int_name,
  ref_name
)

Arguments

data

A data frame containing individual patient data for the relevant time to event outcomes.

time_var

Name of time variable in 'data'. Variable must be numerical and >0.

event_var

Name of event variable in 'data'. Variable must be numerical and contain 1's to indicate an event and 0 to indicate a censor.

weight_var

Optional name of a variable in "data" containing case weights.

model.type

Character vector indicating the types of model formula provided. Permitted values are

  • 'Common shape' a model with a single covariate for the effect of treatment on the scale parameter of the model. The model fit is in the form Surv(Time, Event==1) ~ ARM. The shape parameter is the same for each treatment, and derived directly from the model (no additional manipulation is required). The scale parameter is derived directly from the model for the reference category, however, for the intervention arm, this is calculated as reference shape + treatment effect (shape).

  • 'Independent shape' a model with a single covariate for treatment that affects both the scale and shape parameters of the model. The model fit is in the form Surv(Time, Event==1) ~ ARM + shape(ARM). The scale parameter is derived directly from the model for the reference category, however, for the intervention arm, this is calculated as reference scale + treatment effect (scale). The shape parameter is derived directly from the model for the reference category, however, for the intervention arm, this is calculated as reference shape + treatment effect (shape).

  • 'Separate' a model with no covariates fitted separately to data from each treatment group in a study. The model fit is in the form Surv(Time, Event==1) ~ 1 and is fit twice (one separate model for each of the two treatments). The parameters for each treatment, are derived directly from the model (no additional manipulation is required).

  • 'One arm' a model with no covariates is fitted to the entire data set without a strata variable. The model fit is in the form Surv(Time, Event==1) ~ 1 and is fit to the entire data (no strata). The parameters for each treatment, are derived directly from the model (no additional manipulation is required).

Default is c("Separate", "Common shape", "Independent shape").

distr

A vector string of distributions, see dist argument in flexsurvreg. Default is all available distributions (see below).

strata_var

Name of stratification variable in "data". This is usually the treatment variable and must be categorical. Not required when model.type='One arm'.

int_name

Character to indicate the name of the treatment of interest, must be a level of the "strata_var" column in "data", used for labelling the parameters.

ref_name

Character to indicate the name of the reference treatment, must be a level of the "strata_var" column in "data", used for labelling the parameters. Not required when model.type='One arm'.

Value

A list containing 'models' (models fit using flexsurvreg), 'model_summary' (a tibble containing AIC, BIC and convergence information), 'parameters_vector' (a vector containing the coefficients of each flexsurv model), and 'config' (a list containing information on the function call).

  • 'models' is a list of flexsurv objects for each distribution specified

  • 'model_summary' is a tibble object containing the fitted model objects, the parameter estimates (coef), AIC and BIC from flexsurv objects.

  • 'parameters_vector' is a vector which contains the coefficients for all of the flexsurv models specified. The column names are in the format 'modeltype.distribution.parameter.TreatmentName', for example, comshp.weibull.shape.Int refers to the shape parameter of the common shape weibull distribution for the intervention treatment and 'indshp.gengamma.mu.ref' refers to the mu parameter of the independent shape generalised gamma distribution for the reference treatment. Columns with 'TE' at the end are the treatment effect coefficients (applicable to the scale and shape parameters for independent shape models, applicable to the scale parameter only for the common shape model and not applicable for the separate or one-arm model).

Details

Possible distributions include:

  • Exponential ('exp')

  • Weibull ('weibull')

  • Gompertz ('gompertz')

  • Log-normal ('lnorm')

  • Log-logistic ('llogis')

  • Generalized gamma ('gengamma')

  • Gamma ('gamma')

  • Generalised F ('genf')

For more details and examples see the package vignettes: