[R] Plotting adjusted KM curve

Göran Broström gor@n@bro@trom @end|ng |rom umu@@e
Fri Apr 9 13:13:00 CEST 2021



On 2021-04-05 03:34, Sorkin, John wrote:
> Colleagues,
> I am using the coxph to model survival time. How do I plot an adjusted Kaplan Meir plot resulting from coxph? The code I would like to run would start with:
> 
> # run cox model
> fit1Cox <- coxph(surv_object ~age+sex,data=mydata)
> 
> I have no idea what would follow.

You should look at

?survfit.coxph

in the survival package, especially the 'newdata' argument.
> 
> I would like to plot adjusted KM curves for men vs. women at age 65.

Then I guess that you should stratify on sex:

fit <- coxph(surv_object ~ age + strata(sex), data = mydata)

sfit <- survfit(fit, newdata = data.frame(age = 65))
plot(sfit)

HTW, Göran

> 
> Thank you,
> John
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list