R: Cumulative Incidence Curves for Competing Risks

ggcompetingrisks {survminer} | R Documentation

## Cumulative Incidence Curves for Competing Risks

### Description

This function plots Cumulative Incidence Curves. For `cuminc` objects it's a `ggplot2` version of `plot.cuminc`. For `survfitms` objects a different geometry is used, as suggested by `@teigentler`.

### Usage

    ggcompetingrisks(fit, gnames = NULL, gsep = " ", multiple_panels = TRUE,
      ggtheme = theme_survminer(), coef = 1.96, conf.int = FALSE, ...)

### Arguments

`fit` | an object of a class cuminc - created with cuminc function or `survfitms` created with survfit function.
`gnames` | a vector with group names. If not supplied then will be extracted from `fit` object (`cuminc` only).
`gsep` | a separator that extracts group names and event names from `gnames` object (`cuminc` only).
`multiple_panels` | if `TRUE` then groups will be plotted in different panels (`cuminc` only).
`ggtheme` | function, `ggplot2` theme name. Default value is theme_survminer. Allowed values include ggplot2 official themes: see `theme`.
`coef` | see `conf.int`, scaling actor for the ribbon. The default value is 1.96.
`conf.int` | if `TRUE` then additional layer (`geom_ribbon`) is added around the point estimate. The ribon is plotted with boundries +- `coef`*standard deviation.
`...` | further arguments passed to the function `ggpar` for customizing the plot.

### Value

Returns an object of class `gg`.

### Author(s)

Przemyslaw Biecek, przemyslaw.biecek@gmail.com

### Examples

    set.seed(2)
    ss <- rexp(100)
    gg <- factor(sample(1:3,100,replace=TRUE),1:3,c('BRCA','LUNG','OV'))
    cc <- factor(sample(0:2,100,replace=TRUE),0:2,c('no event', 'death', 'progression'))
    strt <- sample(1:2,100,replace=TRUE)

    # handles cuminc objects
    print(fit <- cmprsk::cuminc(ss,cc,gg,strt))
    ggcompetingrisks(fit)
    ggcompetingrisks(fit, multiple_panels = FALSE)
    ggcompetingrisks(fit, conf.int = TRUE)
    ggcompetingrisks(fit, multiple_panels = FALSE, conf.int = TRUE)

    # handles survfitms objects
    library(survival)
    df <- data.frame(time = ss, group = gg, status = cc, strt)
    fit2 <- survfit(Surv(time, status, type="mstate") ~ 1, data=df)
    ggcompetingrisks(fit2)
    fit3 <- survfit(Surv(time, status, type="mstate") ~ group, data=df)
    ggcompetingrisks(fit3)
    ## Not run:
      library(ggsci)
      library(cowplot)
      ggcompetingrisks(fit3) + theme_cowplot() + scale_fill_jco()

    ## End(Not run)

[Package survminer version 0.4.1 Index]