The Survival Converter calculator converts hazard rate to median survival or survival probability at time \(t\), or alternatively, converts median survival or survival probability at time \(t\) to a hazard rate.

It is not necessary to specify the time unit (years, months, days, etc.), and units are assumed to be consistent between input and output.

Calculations are based on the assumption that event times are exponentially distributed, therefore the relationship between survival proportions and hazard rates is as follows:

\[ \lambda = \frac{-ln(S(t))}{t} \]

where \(\lambda\) represents hazard rate and \(S(t)\) represents survival proportion at time \(t\).

Running the Program

Enter the type of calculation to be performed: hazard rate for a given median survival, hazard rate for a given survival probability at time \(t\), median survival for a given hazard rate, or survival probability for a given hazard rate at time \(t\).

Input Items

The user is prompted for values to one or more of the following items depending on the desired calculation.

Output Items

Statistical Code

The program is written in R.

View Code

function(find, median_survival, survival_time_t, hazard_rate, time) {

    result = list(median = NA,
                  survival = NA,
                  hr = NA)

    if (find == "Median") {
        result$median = -(log(0.5)) / hazard_rate
        result$median = round(result$median, digits = 2)
    } else if (find == "Survival") {
        result$survival = exp(-time * hazard_rate)
        result$survival = round(result$survival, digits = 2)
    } else if (find == "Hazard_Rate") {
        result$hr = -(log(survival_time_t)) / time
        result$hr = round(result$hr, digits = 2)
    } else if (find == "Hazard_Rate_Median") {
        result$hr = -(log(0.5)) / median_survival
        result$hr = round(result$hr, digits = 2)

    return(jsonlite::toJSON(result, pretty = TRUE))