dam4l10
dam4l10

Reputation: 349

Change Kaplan-Meier plot y-axis to failure probability instead of survival probability using survminer (ggsurvplot)?

I am creating a Kaplan-Meier plot that shows the relationship between family history of mental illness and mental illness onset using ggsurvplot from the survminer package. This is the code I have used:

km_fhr <- ggsurvplot(fit = survfit(Surv(fu_time, smidg) ~ fhr, data = df),
                     legend.labs = c("Control", "Family high-risk"),
                     legend.title = "",
                     censor.shape = 124,
                     censor.size = 2.5,
                     palette = c("#00ABE7", "#FFA69E")) +
  labs(x = "Follow-up time (years)", y = "Probability of no SMI diagnosis")

The Kaplan-Meier curve looks like this:

Kaplan-Meier plot

It seems to me that it would be more intuitive to plot risk of illness (failure rate) rather than probability of no illness (survival rate) on the y-axis. I assume there is a simple way to do this, but I have not been able to find a description in the survminer documentation.

Thank you in advance!

Upvotes: 4

Views: 2196

Answers (1)

heds1
heds1

Reputation: 3438

Use the argument fun = event for cumulative events. Reproducible example:

library(survminer)

ggsurvplot(
    survfit(
        Surv(time, status) ~ sex + rx + adhere,
        data = colon
    ),
    fun = "event"
)

plot

From the help for ggsurvplot:

fun: an arbitrary function defining a transformation of the survival curve. Often used transformations can be specified with a character argument: "event" plots cumulative events (f(y) = 1-y), "cumhaz" plots the cumulative hazard function (f(y) = -log(y)), and "pct" for survival probability in percentage.

Upvotes: 5

Related Questions