# Calculate the expected mortality risks from a survival matrix

Source:`R/surv_return.R`

`get_mortality.Rd`

Many methods can be used to reduce a discrete survival distribution prediction (i.e. matrix) to a relative risk / ranking prediction, see Sonabend et al. (2022).

This function calculates a relative risk score as the sum of the
predicted cumulative hazard function, also called **ensemble/expected mortality**.
This risk score can be loosely interpreted as the expected number of deaths for
patients with similar characteristics, see Ishwaran et al. (2008) and has no
model or survival distribution assumptions.

## Arguments

- x
(

`matrix()`

)

A survival matrix where rows are the (predicted) observations and columns the time-points. For more details, see assert_surv_matrix.

## References

Sonabend, Raphael, Bender, Andreas, Vollmer, Sebastian (2022).
“Avoiding C-hacking when evaluating survival distribution predictions with discrimination measures.”
*Bioinformatics*.
ISSN 1367-4803, doi:10.1093/BIOINFORMATICS/BTAC451
, https://academic.oup.com/bioinformatics/advance-article/doi/10.1093/bioinformatics/btac451/6640155.

Ishwaran, Hemant, Kogalur, B U, Blackstone, H E, Lauer, S M, others (2008).
“Random survival forests.”
*The Annals of applied statistics*, **2**(3), 841–860.

## Examples

```
n = 10 # number of observations
k = 50 # time points
# Create the matrix with random values between 0 and 1
mat = matrix(runif(n * k, min = 0, max = 1), nrow = n, ncol = k)
# transform it to a survival matrix
surv_mat = t(apply(mat, 1L, function(row) sort(row, decreasing = TRUE)))
colnames(surv_mat) = 1:k # time points
# get mortality scores (the larger, the more risk)
mort = get_mortality(surv_mat)
mort
#> [1] 42.71302 58.77836 47.27738 45.57169 51.11750 66.17109 40.09711 45.57060
#> [9] 57.89787 51.24080
```