'Making an adjusted Kaplan Meier Surve Curve

I am doing a study looking at the long-term survival of patients admitted to an Intensive Care Unit.

I have done a multivariate Cox regression to describe the association between various variables and long-term survival.

One particular variable of interest is the diagnosis group the patient belongs to.

I would like to include a figure showing the survival curve of the cohort stratified by the 8 diagnosis groups (8 survival curves on the one axes).

However, to truly show how each diagnosis group goes long-term I need to adjust these curves by the variables I have included in the Cox regression.

Here is my code for the survival curves as they are now:

#create survival function
fit <- survfit(Surv(dataset$survivalyrs_2, dataset$status) ~ dataset$apachegroup, data = dataset)


#plot curve and add in matched cohort line
km_curve <- ggsurvplot(fit, 
                   data = dataset, 
                   censor = FALSE,
                   conf.int = TRUE, 
                   risk.table = TRUE,
                   xlab = "Time since Hospital Discharge (years)",  
                   ylab = "Proportion of patients alive", 
                   palette = c("red","orange","yellow","green","blue","brown","pink","black"),
                   legend.title = "Diagnosis",
                   legend.labs = c("Cardiac (Non-surgical)","Cardiac (Surgical)","Gastrointestinal","Neurological","Other","Respiratory","Sepsis","Trauma"))

Does anyone know how to present the adjusted curves? (I've got a heap of variables that I want to adjust for that I won't write down here as it won't really help).



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source