Helper function to transform between CHF and survival function

cumulative_hazard_to_survival(hazard_functions)

Arguments

hazard_functions

matrix or vector, with each row representing a cumulative hazard function

Value

A matrix or vector transformed to the form of a survival function.

Examples

library(survex)

vec <- c(1, 2, 3, 4, 5)
matr <- matrix(c(1, 2, 3, 2, 4, 6), ncol = 3)

cumulative_hazard_to_survival(vec)
#> [1] 0.367879441 0.135335283 0.049787068 0.018315639 0.006737947

cumulative_hazard_to_survival(matr)
#>           [,1]       [,2]        [,3]
#> [1,] 0.3678794 0.04978707 0.018315639
#> [2,] 0.1353353 0.13533528 0.002478752