Skip to contents

This function calculates the overall median survival time for a mixed population composed of multiple subgroups, each following exponential distributions with different median survival times. The overall population follows a mixture of exponential distributions with mixing probabilities based on expected event counts.

Usage

mstfromExpdists(expected_events, MST_subgroups, search_range = c(0, 100))

Arguments

expected_events

Numeric vector of expected event counts for each subgroup

MST_subgroups

Numeric vector of median survival times for each subgroup (same length as expected_events)

search_range

Numeric vector of length 2 specifying the search interval for uniroot (default: c(0, 100))

Value

List containing:

subgroup_summary

Data frame with subgroup details (subgroup, expected_events, MST)

MST_overall

Overall median survival time for the mixed population

Details

The function assumes that each subgroup follows an exponential distribution with the specified median survival time. The overall population is modeled as a mixture of exponential distributions with mixing probabilities proportional to expected event counts.

Mathematical formulation: $$S(t) = \sum_{j=1}^{k} p_j \exp(-\lambda_j t)$$ where \(p_j = E_j / \sum E_j\) is the mixing probability for subgroup j based on expected events, \(\lambda_j = \ln(2) / MST_j\) is the hazard rate for subgroup j, and \(MST_j\) is the median survival time for subgroup j.

The overall median survival time is found by solving: $$S(t_{median}) = 0.5$$

Examples

# Example 1: Two subgroups with different expected event counts
expected_events <- c(75, 120)  # Expected events, not sample sizes
MST_subgroups <- c(6, 7.5)
result <- mstfromExpdists(expected_events, MST_subgroups)
print(result$subgroup_summary)
#>   subgroup expected_events MST
#> 1        1              75 6.0
#> 2        2             120 7.5
print(paste("Overall MST:", round(result$MST_overall, 2), "months"))
#> [1] "Overall MST: 6.87 months"

# Example 2: Three subgroups
expected_events <- c(150, 180, 60)  # Based on expected event rates
MST_subgroups <- c(8, 12, 15)
result <- mstfromExpdists(expected_events, MST_subgroups)
print(result$subgroup_summary)
#>   subgroup expected_events MST
#> 1        1             150   8
#> 2        2             180  12
#> 3        3              60  15
print(paste("Overall MST:", round(result$MST_overall, 2), "months"))
#> [1] "Overall MST: 10.54 months"