Calculate Trauma Hospital Performance Based on Robust and Validated Measures
Source:R/trauma_performance.r
trauma_performance.Rd
This function calculates trauma hospital performance based on the M, W, and Z scores, which are derived from survival probability and mortality data, using established methods. It computes the W-score, M-score, and Z-score based on the provided dataset and calculates performance metrics for trauma programs. For more information on the methods used in this function, please see Champion et al. (1990) on the W score, and Flora (1978) and Boyd et al. (1987) on the M and Z scores.
Usage
trauma_performance(
df,
Ps_col,
outcome_col,
outcome = 1,
z_method = c("survival", "mortality"),
diagnostics = FALSE
)
Arguments
- df
A data frame containing patient data.
- Ps_col
The name of the column containing the probability of survival (Ps). The values should be numeric and between 0 and 1. Values greater than 1 will be automatically converted to decimal format by dividing by 100.
- outcome_col
The name of the column containing the binary outcome data.
The column should contain binary values indicating the patient outcome. Valid values include 1 (dead) and 0 (alive), or TRUE (dead) and FALSE (alive), or other similar binary representations (e.g., "Yes" for dead and "No" for alive). The function will check for two unique values in this column and expects them to represent the outcome in a binary form.
- outcome
The value representing mortality (default is 1). Can also be set to 0 or TRUE/FALSE, depending on how the outcome is encoded in
outcome_col
.- z_method
A character vector indicating which method to use for calculating the Z-score. Must be one of "survival" or "mortality". The default is "survival".
- diagnostics
A logical flag (default is FALSE). If TRUE, diagnostic information about the W, M, and Z scores will be printed to the console.
Value
A tibble containing the following calculations:
N_Patients
: The total number of patients included in the analysis.N_Survivors
: The total number of patients who survived, based on the provided outcome data.N_Deaths
: The total number of patients who died, based on the provided outcome data.Predicted_Survivors
: The total predicted number of survivors based on the survival probability (Ps
) for all patients.Predicted_Deaths
: The total predicted number of deaths, calculated as1 - Ps
for all patients.Patient_Estimate
: The estimated number of patients who survived, calculated based on the W-score. This value reflects the difference between the actual and predicted number of survivors.W_Score
: The W-score, representing the difference between the observed and expected number of survivors per 100 patients. A positive W-score indicates that more patients survived than expected, while a negative score indicates that fewer patients survived than expected.M_Score
: The M-score, which compares the observed patient case mix to the Major Trauma Outcomes Study (MTOS) case mix. A higher score indicates that the patient mix is more similar to MTOS, while a lower score indicates a dissimilar mix. Based on the MTOS literature, an M_Score >= 0.88 indicates that the Z_Score comes from distribution similar enough to the MTOS Ps distribution.Z_Score
: The Z-score, which quantifies the difference between the actual and predicted mortality (ifz_method = "mortality"
) or survival (ifz_method = "survival"
). A Z-score > 1.96 is considered to point to the statistical significance of the W-Score at alpha = 0.05 level for survival. The positive Z_Score indicates that more patients survived than predicted, while a negative Z-score indicates fewer survivors than predicted.
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))
# Calculate trauma performance (W, M, Z scores)
trauma_performance(data, Ps_col = Ps, outcome_col = death)
#> # A tibble: 9 × 2
#> Calculation_Name Value
#> <chr> <dbl>
#> 1 N_Patients 10000
#> 2 N_Survivors 8137
#> 3 N_Deaths 1863
#> 4 Predicted_Survivors 8097.
#> 5 Predicted_Deaths 1903.
#> 6 Patient_Estimate 40.3
#> 7 W_Score 0.403
#> 8 M_Score 0.374
#> 9 Z_Score 1.18