kassambara / survminer

Survival Analysis and Visualization
https://rpkgs.datanovia.com/survminer/
491 stars 160 forks source link

R: ggsurvplot covariate-adjusted cumulative hazard graphs #580

Open ohminoh opened 2 years ago

ohminoh commented 2 years ago

I'm trying to generate discrete-time cumulative hazard plots for each value in my grouping variable (i.e., each group is a student category), while controlling for a covariate (e.g., gender).

As you can see here, I have 9 panels, where one panel represents the hazard ratios for each of the 9 group categories. I used this command:

cumuhaz.sped0 <- ggsurvplot(survfit(surv_object ~ langstatus_new + (1 | deident_studnum) + (1 | sch_id) + (1 | district), data=mydata), pvalue=TRUE, conf.int = TRUE,fun = "cumhaz", data=mydata) cumuhaz.sped0$plot + theme_bw() + facet_wrap(~langstatus_new)

Now, I want to see how the line changes when accounting/controlling for students' household income status (0 = high income, 1 = low income). So I used this:

cumuhaz.sped <- ggsurvplot(survfit(surv_object ~ langstatus_new + lowincome + (1 | deident_studnum) + (1 | sch_id) + (1 | district), data=mydata), pvalue=TRUE, conf.int = TRUE,fun = "cumhaz", data=mydata) cumuhaz.sped$plot + theme_bw() + facet_wrap(~langstatus_new)

But when I do this--with the expectation that I will see 9 panels, each with one line where income status is controlled for--I see TWO lines in each panel, where each line represents low vs high income status (like this). How would I need to change the syntax to just see 1 line per panel, that just tells me what the adjusted hazard ratios are for each group (i.e., panel)?

Relatedly, which command would allows me to see the specific hazard ratio value at each timepoint? This would be super helpful!

Apologies in advance if anything is confusing. I'm happy to clarify. I assume this is a simple fix, but I've been wrestling with it for too long!

RobinDenz1 commented 2 years ago

I would suggest using confounder-adjusted survival curves or confounder-adjusted cumulative incidence functions to present your results instead. The ggadjustedcurves function in this package might help you with that. Alternatively, you could use the adjustedCurves package (see https://github.com/RobinDenz1/adjustedCurves).