
Create a Cox Proportional Hazards Model with Splines and Covariates
Source:R/cox_analysis.R
cox_create_model.RdConstructs a Cox model using a survival formula and allows for the inclusion of both regular covariates and spline-transformed continuous variables.
Arguments
- cox_model_data
A data frame containing the variables required for the model, including survival time variables and covariates.
- normal_vars
A character vector of covariate names to be included as standard (non-spline) variables in the model (e.g., `"edu"`).
- spline_vars
A character vector of continuous variables for which natural cubic splines will be used (via `splines::bs()`).
- surv_formula
A character string specifying the survival outcome in `Surv()` notation. Currently not parsed dynamically; the function uses `Surv(tstart, tstop, diagnose)` internally.
- id_var
A string giving the column name for individual-level IDs to be used in the `coxph()` call.