R/utils-survival.R
observed_vs_expected_mortality.Rd
This function creates a table to compare the observed and the expected mortality.
observed_vs_expected_mortality(x, f, time, expected)
Surv
, object
factor
, strata/splitting factor
numeric(1)
, observed/expected survival at time
timepoint.
numeric
, expected mortality rate, has to be of the same
length as levels in f
.
data.frame
, with observed/expected mortality rates and events.
sv <- Surv(1:8, c(0, 1, 1, 0, 1, 1, 1, 0))
f <- factor(rep(c("a", "c"), 4), levels = c("a", "b", "c"))
observed_vs_expected_mortality(sv, f, time = 3, expected = c(0.5, 0.3, 0.2))
#> ObservedDeaths ExpectedDeaths StandardizedMortalityRatio ObservedMortality
#> a 1 1.5 0.6666667 0.3333333
#> b NA NA NA NA
#> c 1 0.8 1.2500000 0.2500000
#> ExpectedMortality
#> a 0.5
#> b 0.3
#> c 0.2