Helper function to transform between survival function and CHF

survival_to_cumulative_hazard(survival_functions, epsilon = 0)

Arguments

survival_functions

matrix or vector, with each row representing a survival function

epsilon

a positive numeric number to add, so that the logarithm can be taken

Value

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

Examples

library(survex)

vec <- c(1, 0.9, 0.8, 0.7, 0.6)
matr <- matrix(c(1, 0.9, 0.8, 1, 0.8, 0.6), ncol = 3)

survival_to_cumulative_hazard(vec)
#> [1] 0.0000000 0.1053605 0.2231436 0.3566749 0.5108256

survival_to_cumulative_hazard(matr)
#>           [,1]      [,2]      [,3]
#> [1,] 0.0000000 0.2231436 0.2231436
#> [2,] 0.1053605 0.0000000 0.5108256