Khalid
Khalid

Reputation: 23

cox regression plot using R

I have a Cox proportional hazards model set up using the following code in R that predicts mortality. Covariates A, B and C are added simply to avoid confounding (i.e. age, sex, race) but we are really interested in the predictor X. Where X is a medication that lowers the risk of mortality (our hypothesis).

so I want to make a cox survival plot to show a comparison between the two groups (X=0 and X=1) with adjustment of other covariates (A,B,C).

I've started with first step

cox.model <- coxph(Surv(time, dead) ~ A + B + C + X, data = df)

then I used this code to make the cox plot

ggsurvplot(survfit(cox.model), data = df, palette = "#2E9FDF",
       ggtheme = theme_minimal(),
       risk.table = TRUE)

it gave me a plot with just one (cumulative) line, not comparing between (X=1 and X=0), even the risk table was just one group.

my question is how I can show the comparison in that plot? also how to show the two groups in the risk table?

Note: it was easy for me when I did KM to make a comparison without adjustment for co-variates A+ B+ C .

Upvotes: 1

Views: 330

Answers (0)

Related Questions