I am trying to plot adjusted Kaplan-Meier curves. I know publications like to see something graphical. But using R, I don't know how to go about adjusting for something like age, gender, income when graphing a survival curve.

Otherwise my curves will always be just crude and unadjusted, which I'm guessing people will not like. Any ideas?

I have 4 groups to compare.


The only way to provide differential survival with true KM curves is to generate new curves for different groups. You could then display a curve for all persons of group 3, for example. The number of units in each group will decrease as the number of strata increase. However, this method is empiric and does not truly adjust the sample to some chosen set of values.

I am most familiar with methods for obtaining adjusted curves derived from Cox or parametric survival models. Generally speaking, the role of an adjusted curve is to graphically display the expected mortality (or mortality transformed to survival) of the sample if a single or combination of values is set to some fixed value or set of values, respectively.

For example, one might find from a Cox model the hazard ratio for blood pressure is 1.1. Thus, for each 1 unit increase in blood pressure, the average hazard at a given time point multiplies by 1.1. Now, if we wanted to display the mortality curve for all units under analysis (sample) adjusted to a blood pressure of 1 standard deviation above the mean, we could display an adjusted curve.

Here is a self-contained example using group for your reference. Note that the final, adjusted curve is for the mean of group which, for most applications, would have no real meaning. Also note that transformation from mortality to survival are required for this method.


days <- rpois(100, 3)
status <- rbinom(100,1,0.34)
group <- sample(c(1,2,3,4), 100, replace=TRUE)
df <- data.frame(days, status)

#overall survival
surv <- survfit(Surv(days, status)~1)

#survival by group
kmsurv <- survfit(Surv(days,status) ~ strata(group), df)

#survival adjusted to group effect
cox <- coxph(Surv(days,status)~group, df)

Essential information on the R code can be found here.

Lastly, it is my opinion that adjusted survival analysis is generally statistical sleight of hand as the adjustment process can 1) be used for unrealistic patterns of covariates, 2) fool the reader into believing that non-significant effects can result in some displayed survival/mortality pattern and 3) be confused with empiric curves, leading readers to believe you have more events or information for each subgroup/pattern than you actually possess. I would carefully consider why adjusted curves are desirable over adjusted hazard ratios before spending too much time.

| cite | improve this answer | |
  • $\begingroup$ +1. I particularly agree with the cautions about how adjusted survival curves can be misleading. $\endgroup$ – EdM Aug 28 '16 at 22:23
  • 1
    $\begingroup$ I also strongly suggest plotting the raw KM curves, rather than adjusted Cox PH curves. By plotting the KM curves, a reader can quickly visualize how reasonable the PH assumption is. With the Cox PH adjusted curve, it automatically looks perfect (even if it's horrible). $\endgroup$ – Cliff AB Aug 28 '16 at 23:00

There is a lot of literature on the subject and there is also some R Code available.

The method Todd D described is known as average method and it is conceptually and empirically biased (See for example Nieto (1996). It is generally recommended to use direct adjustment or conditional adjustment instead.

The survminer package contains a function called ggadjustedcurves which implements direct adjustment (given a cox model) in the method marginal. A non-parametric method to adjust survival curves, which is based on a weighted kaplan-meier estimator, can be found in Xie (2000). This method and a corresponding weighted log-rank test are implemented in the R-Package RISCA.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.