aalen_johansen() estimates the cumulative incidence function of each cause when subjects can
have one of several kinds of event. The cumulative incidence \(F_k(t)\) is the probability of
having an event of cause \(k\) by time \(t\). Unlike one minus a Kaplan-Meier curve that
treats the other causes as censoring, it accounts for subjects who can no longer have the event
because another one happened first, so the incidences of all causes add up to the probability
of any event.
Arguments
- formula
A formula with a competing-risks
Surv()response on the left and either1or the grouping variables on the right. The response isSurv(time, event)witheventa factor: its first level means censored and each other level is a cause, as inSurv(time, factor(status, 0:2, c("censor", "pcm", "death"))) ~ sex.- data
A data frame holding the variables in
formula.- subset
An optional expression selecting the rows of
datato use.- na.action
What to do with rows that have missing values. The default drops them.
- conf_type
The scale of the confidence limits:
"plain"(the default),"log", or"log-log".- conf_level
The confidence level, between 0 and 1. The default is
0.95.
Value
An aalen_johansen object. as.data.frame() gives the estimates with one row per
group, cause, and distinct time: strata, the grouping variables, cause, time, n_risk,
estimate, std_error, conf_low, and conf_high. The layout is the same for one group
(strata is "all") as for several. predict() reads the curves at given times.
Details
At each distinct time \(t_j\), with \(n_j\) subjects at risk, \(d_{kj}\) events of cause \(k\), and \(\hat S(t_{j-1})\) the Kaplan-Meier estimate of being free of any event just before, the estimate is $$\hat F_k(t) = \sum_{t_j \le t} \hat S(t_{j-1}) \frac{d_{kj}}{n_j}.$$ The standard error is the delta-method one. Confidence limits are built on the plain scale (the default), the log scale, or the log-log scale, and kept within 0 and 1. The log and log-log limits are missing where the estimate is 0 or 1.
See also
grays_test() to compare cumulative incidence between groups, fine_gray() to model
it, and multi_state() for more general state structures.
Examples
mgus <- data.frame(
time = c(30, 45, 60, 72, 80, 95, 110, 120, 130, 150, 160, 180),
status = c(1, 2, 0, 2, 1, 2, 0, 1, 2, 2, 0, 1),
sex = rep(c("F", "M"), times = 6)
)
mgus$event <- factor(mgus$status, levels = 0:2, labels = c("censor", "pcm", "death"))
fit <- aalen_johansen(Surv(time, event) ~ 1, data = mgus)
fit
#> <aalen_johansen> Surv(time, event) ~ 1
#> n = 12. Events: pcm = 4, death = 5
#>
#> Cumulative incidence at the last time (plain limits):
#> cause time estimate std_error conf_low conf_high
#> pcm 180 0.5093 0.1588 0.1980 0.8205
#> death 180 0.4907 0.1588 0.1795 0.8020
as.data.frame(fit)
#> strata cause time n_risk estimate std_error conf_low conf_high
#> 1 all pcm 30 12 0.08333333 0.07978559 0.000000000 0.2397102
#> 2 all pcm 45 11 0.08333333 0.07978559 0.000000000 0.2397102
#> 3 all pcm 60 10 0.08333333 0.07978559 0.000000000 0.2397102
#> 4 all pcm 72 9 0.08333333 0.07978559 0.000000000 0.2397102
#> 5 all pcm 80 8 0.17592593 0.11332878 0.000000000 0.3980462
#> 6 all pcm 95 7 0.17592593 0.11332878 0.000000000 0.3980462
#> 7 all pcm 110 6 0.17592593 0.11332878 0.000000000 0.3980462
#> 8 all pcm 120 5 0.28703704 0.14186288 0.008990905 0.5650832
#> 9 all pcm 130 4 0.28703704 0.14186288 0.008990905 0.5650832
#> 10 all pcm 150 3 0.28703704 0.14186288 0.008990905 0.5650832
#> 11 all pcm 160 2 0.28703704 0.14186288 0.008990905 0.5650832
#> 12 all pcm 180 1 0.50925926 0.15881872 0.197980297 0.8205382
#> 13 all death 30 12 0.00000000 0.00000000 0.000000000 0.0000000
#> 14 all death 45 11 0.08333333 0.07978559 0.000000000 0.2397102
#> 15 all death 60 10 0.08333333 0.07978559 0.000000000 0.2397102
#> 16 all death 72 9 0.17592593 0.11332878 0.000000000 0.3980462
#> 17 all death 80 8 0.17592593 0.11332878 0.000000000 0.3980462
#> 18 all death 95 7 0.26851852 0.13304760 0.007750005 0.5292870
#> 19 all death 110 6 0.26851852 0.13304760 0.007750005 0.5292870
#> 20 all death 120 5 0.26851852 0.13304760 0.007750005 0.5292870
#> 21 all death 130 4 0.37962963 0.15178942 0.082127832 0.6771314
#> 22 all death 150 3 0.49074074 0.15881872 0.179461778 0.8020197
#> 23 all death 160 2 0.49074074 0.15881872 0.179461778 0.8020197
#> 24 all death 180 1 0.49074074 0.15881872 0.179461778 0.8020197
# One set of curves per sex, read at given times
by_sex <- aalen_johansen(Surv(time, event) ~ sex, data = mgus, conf_type = "log-log")
predict(by_sex, times = c(50, 100))
#> strata sex cause time estimate std_error conf_low conf_high
#> 1 sex=F F pcm 50 0.1666667 0.1521452 0.007723104 0.5168018
#> 2 sex=F F pcm 100 0.3750000 0.2134781 0.046917146 0.7301888
#> 3 sex=F F death 50 0.0000000 0.0000000 NaN NaN
#> 4 sex=F F death 100 0.0000000 0.0000000 NaN NaN
#> 5 sex=M M pcm 50 0.0000000 0.0000000 NaN NaN
#> 6 sex=M M pcm 100 0.0000000 0.0000000 NaN NaN
#> 7 sex=M M death 50 0.1666667 0.1521452 0.007723104 0.5168018
#> 8 sex=M M death 100 0.5000000 0.2041241 0.110948260 0.8037092