View the Current Patient Population Case Mix Compared to the Major Trauma Study Case Mix
Source:R/trauma_case_mix.r
trauma_case_mix.Rd
This function compares the current patient population's case mix (based on probability of survival, Ps) to the MTOS case mix by binning patients into specific Ps ranges. It returns the fraction of patients in each range and compares it to the MTOS distribution. For more information on the methods used in these calculations, please see Flora (1978) and Boyd et al. (1987).
Value
A data frame containing the Ps ranges, the fraction of patients in each range in the current population, and the MTOS distribution for each range.
Details
The function checks whether the outcome_col
contains exactly two
unique values representing a binary outcome. It also ensures that Ps_col
contains numeric values within the range 0 to 100. If any values exceed 1,
they are converted to decimal format. The patients are then grouped into
predefined Ps ranges, and the function compares the fraction of patients in
each range with the MTOS case mix distribution.
Examples
# Generate example data with high negative skewness
set.seed(123)
# Parameters
n_patients <- 10000 # Total number of patients
# Generate survival probabilities (Ps) using a logistic distribution
set.seed(123) # For reproducibility
Ps <- plogis(rnorm(n_patients, mean = 2, sd = 1.5)) # Skewed towards higher values
# Simulate survival outcomes based on Ps
survival_outcomes <- rbinom(n_patients, size = 1, prob = Ps)
# Create data frame
data <- data.frame(Ps = Ps, survival = survival_outcomes) |>
dplyr::mutate(death = dplyr::if_else(survival == 1, 0, 1))
# Compare the current case mix with the MTOS case mix
trauma_case_mix(data, Ps_col = Ps, outcome_col = death)
#> Ps_range current_fraction MTOS_distribution
#> 1 0.00 - 0.25 0.0209 0.010
#> 2 0.26 - 0.50 0.0742 0.043
#> 3 0.51 - 0.75 0.1907 0.000
#> 4 0.76 - 0.90 0.3000 0.052
#> 5 0.91 - 0.95 0.1979 0.053
#> 6 0.96 - 1.00 0.2163 0.842