This functions calculate some survival information (e.g. survival rate, mortality rate).
observed_survival(x, f, times)
observed_mortality(x, f, times)
observed_events(x, f, times, cumulative = FALSE)
Surv
, object
factor
, strata/splitting factor
numeric
, information at times
logical
, if TRUE
(default FALSE
) and multiple times
are given the cumulative events are reported instead of the events in the
time periods.
double
, with an element for each level in f
,
if times is a numeric
of length 1; or a matrix
with
as much rows as elements in times
and a column for each level in f
.
In contrast to survival::summary.survfit()
these functions do not remove
empty strata (e.g. important for bootstrapping).
sv <- Surv(1:4, c(0, 1, 1, 0))
f <- factor(c("a", "c", "a", "c"), levels = c("a", "b", "c"))
observed_survival(sv, times = 3)
#> [1] 0.3333333
observed_survival(sv, f = f, times = 3)
#> a b c
#> 0.0 NA 0.5
observed_survival(sv, f = f, times = 1:4)
#> a b c
#> 1 1 NA 1.0
#> 2 1 NA 0.5
#> 3 0 NA 0.5
#> 4 0 NA 0.5
observed_mortality(sv, f = f, times = 3)
#> a b c
#> 1.0 NA 0.5
observed_events(sv, f = f, times = 3)
#> a b c
#> 1 NA 1
observed_events(sv, f = f, times = 1:4)
#> a b c
#> 1 0 NA 0
#> 2 0 NA 1
#> 3 1 NA 0
#> 4 0 NA 0
observed_events(sv, f = f, times = 1:4, cumulative = TRUE)
#> a b c
#> 1 0 NA 0
#> 2 0 NA 1
#> 3 1 NA 1
#> 4 1 NA 1