I would recommend staying away from the survminer
package, at least until you know a lot more about survival analysis. It has serious software glitches that weren't fixed when last I looked, and I don't think it provides a very good introduction to the basic principles of survival analysis.
Start instead with the basic survival
package that comes with R. Although it doesn't fit so nicely into the "tidyverse" as survminer
, it has a superb set of vignettes that explain the basis of how to accomplish many types of tasks in survival analysis. The main package vignette is a particularly useful overview.
When you do that, you will find that a Cox model with treatments and grade as predictors will probably accomplish what you want. For example, the model
mod1 <- coxph(Surv(time, status) ~ treatment + factor(grade))
will allow you to "adjust for" grade in a way that's the same for all treatments. The baseline survival curve will be for the baseline levels of treatment
and grade
; the 2 regression coefficients for treatment
will indicate the differences in log-hazard from baseline associated each of those treatment
types after "adjusting for" grade. As a bonus, you get estimates of the associations of other levels of grade
with outcome, "adjusted for" treatment.
You can evaluate whether there are any differences associated with treatment
by an anova()
comparison of the above model against
mod0 <- coxph(Surv(time, status) ~ factor(grade))
provided that you do build both models on the same individuals. Post-modeling software like that of the emmeans
package can evaluate pairwise differences among treatments.