plot_cif() draws the cumulative incidence curves of an aalen_johansen() fit, one panel per
cause, as step functions with their pointwise confidence bands. A fit with groups has one curve
per group in each panel, told apart by color.
Usage
plot_cif(
fit,
conf_int = TRUE,
risk_table = FALSE,
times = NULL,
title = NULL,
xlab = "Time",
ylab = "Cumulative incidence"
)Arguments
- fit
An
aalen_johansen()fit.- conf_int
Draw the confidence bands.
- risk_table
Stack a numbers-at-risk table under the curves.
- times
The times of the numbers-at-risk table. The default is six evenly spaced, rounded times from 0 to the end of follow-up.
- title
An optional plot title.
- xlab, ylab
The axis labels.
Details
With risk_table = TRUE, the numbers at risk (see risk_table()) are stacked under the panels.
This needs the patchwork package, and the result is a patchwork.
Examples
status <- with(mgus2, ifelse(pstat == 1, 1, 2 * death))
time <- with(mgus2, ifelse(pstat == 1, ptime, futime))
mgus <- data.frame(
time = time,
event = factor(status, 0:2, c("censor", "progression", "death")),
sex = mgus2$sex
)
fit <- aalen_johansen(Surv(time, event) ~ sex, data = mgus)
plot_cif(fit)