An open API service indexing awesome lists of open source software.

https://github.com/bemts-hhs/traumar

Functions to help with data analytics in the injury epidemiology field.
https://github.com/bemts-hhs/traumar

ems mortality pi probability quality r survival trauma triss

Last synced: 12 months ago
JSON representation

Functions to help with data analytics in the injury epidemiology field.

Awesome Lists containing this project

README

          

---
output: github_document
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)

library(traumar)

```

[![R-CMD-check](https://github.com/bemts-hhs/traumar/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/bemts-hhs/traumar/actions/workflows/R-CMD-check.yaml)
[![CRAN status](https://www.r-pkg.org/badges/version/traumar)](https://CRAN.R-project.org/package=traumar)
[![Codecov test coverage](https://codecov.io/gh/bemts-hhs/traumar/graph/badge.svg)](https://app.codecov.io/gh/bemts-hhs/traumar)

# traumar

Continuous Quality Improvement (CQI) and Process Improvement (PI) are essential
pillars of healthcare, particularly in the care of injured patients. However,
hospitals, trauma systems, and their trauma program managers (TPMs) often lack
access to standardized quality measures derived from academic literature. The
{traumar} package addresses this gap by providing tools to calculate quality
measures related to relative mortality efficiently and accurately. By automating
these calculations, {traumar} empowers hospital systems, trauma networks, and
TPMs to focus their efforts on analyzing outcomes and driving meaningful
improvements in patient care. Whether you're seeking to enhance PI initiatives
or streamline CQI processes, {traumar} serves as a valuable resource for
advancing trauma care quality.

## Installation

You can install the development version of `traumar` from [GitHub](https://github.com/bemts-hhs/traumar) with:

``` r
# install.packages("remotes")
remotes::install_github("bemts-hhs/traumar")
```

Additionally, you can install the CRAN version of `traumar` via:

```r
install.packages("traumar")
```

## Helper Functions

{traumar} has many functions to help you in your data analysis journey! In
particular, if you do not presently have access to probability of survival data,
{traumar} provides the `probability_of_survival()` function to do just that
using the TRISS method. Check out the additional package documentation at
https://bemts-hhs.github.io/traumar/ where you can
find examples of each function the package has to offer.

## Calculating the W-Score

The W-Score tells us how many survivals (or deaths) on average out of every 100
cases seen in a trauma center. Using R, we can do this with the {traumar}
package.

### First, we will create the data for these examples

```{r all_data}

# 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
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))

```

### The W-Score!

```{r w_score}

# Calculate trauma performance (W, M, Z scores)
trauma_performance(data, Ps_col = Ps, outcome_col = death)

```

## Comparing the Probability of Survival Distribution of your Patient Mix to the [Major Trauma Outcomes Study](https://journals.lww.com/jtrauma/Abstract/1990/11000/The_Major_Trauma_Outcome_Study__Establishing.8.aspx)

The M and Z scores are calculated using methods defined in the
[literature](https://journals.lww.com/jtrauma/abstract/1978/10000/a_method_for_comparing_survival_of_burn_patients.3.aspx)
may not be meaningful if your the distribution of the probability of survival
measure is not similar enough to the Major Trauma Outcomes Study distribution.
{traumar} provides a way to check this in your data analysis script, or even
from the console. The `trauma_performance()` function does this under the hood
for you, so you can get a read out of how much confidence you can put into the Z
score.

```{r trauma_case_mix}

# Compare the current case mix with the MTOS case mix
trauma_case_mix(data, Ps_col = Ps, outcome_col = death)

```

## The Relative Mortality Metric

Napoli et al.(2017) published methods for calculating a measure of trauma center
(or system) performance while overcoming a problem with the W-Score and the
TRISS methodology. Given that the majority of patients seen at trauma centers
will have a probability of survival over 90%, estimating performance based on
the W-Score may only indicate how well a center performed with lower acuity
patients. Using Napoli et al. (2017), it is possible to calculate a score that
is similar to the W-Score in its interpretability, but deals with the negatively
skewed probability of survival problem by creating non-linear bins of score
ranges, and then weighting a score based on the nature of those bins. The
Relative Mortality Metric (RMM) has a scale from -1 to 1.

* An RMM of 0 indicates that the observed mortality aligns with the expected
national benchmark across all acuity levels.
* An RMM greater than 0 indicates better-than-expected performance, where
the center is outperforming the national benchmark.
* An RMM less than 0 indicates under-performance, where the center’s observed
mortality is higher than the expected benchmark.

## Non-Linear Binning Algorithm

An important part of the approach Napoli et al. (2017) took was to modify the
M-Score approach of looking at linear bins of the probability of survival
distribution, and make it non-linear. The {traumar} package does this for you
using Dr. Napoli's method:

``` {r non_linear}

# Apply the nonlinear_bins function
results <- nonlinear_bins(data = data,
Ps_col = Ps,
outcome_col = survival,
divisor1 = 4,
divisor2 = 4,
threshold_1 = 0.9,
threshold_2 = 0.99)

# View intervals created by the algorithm
results$intervals

# View the bin statistics
results$bin_stats

```

## The RMM function

The RMM is sensitive to higher acuity patients, meaning that if a trauma center
struggles with these patients, it will be reflected in the RMM. In contrast, the
W-Score may mask declines in performance due to the influence of lower acuity
patients via the MTOS Distribution. The {traumar} package automates RMM
calculation as a single score using the nonlinear binning method from Napoli et
al. (2017). The `rmm()` and `rm_bin_summary()` functions internally call
`nonlinear_bins()` to generate the non-linear binning process. The function uses
a bootstrap process with `n_samples` repetitions to simulate an RMM distribution and
estimate 95% confidence intervals. The RMM, along with corresponding
confidence intervals, are provided for the population in `data`, as well.

```{r rmm}

# Example usage of the `rmm()` function
rmm(data = data,
Ps_col = Ps,
outcome_col = survival,
n_samples = 250,
Divisor1 = 4,
Divisor2 = 4
)

# Pivoting can be helpful at times
rmm(
data = data,
Ps_col = Ps,
outcome_col = survival,
n_samples = 250,
Divisor1 = 4,
Divisor2 = 4,
pivot = TRUE
)

# RMM calculated by non-linear bin range
# `rm_bin_summary()` function
rm_bin_summary(data = data,
Ps_col = Ps,
outcome_col = survival,
Divisor1 = 4,
Divisor2 = 4,
n_samples = 250
)

```