{"id":26940474,"url":"https://github.com/bemts-hhs/traumar","last_synced_at":"2025-04-02T15:18:46.727Z","repository":{"id":273892715,"uuid":"918442821","full_name":"bemts-hhs/traumar","owner":"bemts-hhs","description":"Functions to help with data analytics in the injury epidemiology field.","archived":false,"fork":false,"pushed_at":"2025-03-25T04:44:11.000Z","size":9210,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T05:19:31.429Z","etag":null,"topics":["ems","mortality","pi","probability","quality","r","survival","trauma","triss"],"latest_commit_sha":null,"homepage":"https://bemts-hhs.github.io/traumar/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bemts-hhs.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-18T00:19:36.000Z","updated_at":"2025-03-25T04:36:36.000Z","dependencies_parsed_at":"2025-01-23T16:25:26.853Z","dependency_job_id":"fab4d525-4ccb-459b-9266-8c64ce68e7f6","html_url":"https://github.com/bemts-hhs/traumar","commit_stats":null,"previous_names":["bemts-hhs/traumar"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bemts-hhs%2Ftraumar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bemts-hhs%2Ftraumar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bemts-hhs%2Ftraumar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bemts-hhs%2Ftraumar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bemts-hhs","download_url":"https://codeload.github.com/bemts-hhs/traumar/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246837628,"owners_count":20841906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ems","mortality","pi","probability","quality","r","survival","trauma","triss"],"created_at":"2025-04-02T15:18:46.216Z","updated_at":"2025-04-02T15:18:46.718Z","avatar_url":"https://github.com/bemts-hhs.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r setup, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n\nlibrary(traumar)\n\n```\n\n\u003c!-- badges: start --\u003e\n[![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)\n[![CRAN status](https://www.r-pkg.org/badges/version/traumar)](https://CRAN.R-project.org/package=traumar)\n[![Codecov test coverage](https://codecov.io/gh/bemts-hhs/traumar/graph/badge.svg)](https://app.codecov.io/gh/bemts-hhs/traumar)\n\u003c!-- badges: end --\u003e\n\n# traumar \u003cimg src=\"man/figures/try_object.png\" align=\"right\" width=\"200\" style=\"display: block; margin: auto;\" /\u003e\n\nContinuous Quality Improvement (CQI) and Process Improvement (PI) are essential\npillars of healthcare, particularly in the care of injured patients. However,\nhospitals, trauma systems, and their trauma program managers (TPMs) often lack\naccess to standardized quality measures derived from academic literature. The\n{traumar} package addresses this gap by providing tools to calculate quality\nmeasures related to relative mortality efficiently and accurately. By automating\nthese calculations, {traumar} empowers hospital systems, trauma networks, and\nTPMs to focus their efforts on analyzing outcomes and driving meaningful\nimprovements in patient care. Whether you're seeking to enhance PI initiatives\nor streamline CQI processes, {traumar} serves as a valuable resource for\nadvancing trauma care quality.\n\n## Installation\n\nYou can install the development version of `traumar` from [GitHub](https://github.com/bemts-hhs/traumar) with:\n\n``` r\n# install.packages(\"remotes\")\nremotes::install_github(\"bemts-hhs/traumar\")\n```\n\nAdditionally, you can install the CRAN version of `traumar` via:\n\n```r\ninstall.packages(\"traumar\")\n```\n\n## Helper Functions\n\n{traumar} has many functions to help you in your data analysis journey! In\nparticular, if you do not presently have access to probability of survival data,\n{traumar} provides the `probability_of_survival()` function to do just that\nusing the TRISS method. Check out the additional package documentation at\nhttps://bemts-hhs.github.io/traumar/ where you can\nfind examples of each function the package has to offer.\n\n## Calculating the W-Score\n\nThe W-Score tells us how many survivals (or deaths) on average out of every 100\ncases seen in a trauma center.  Using R, we can do this with the {traumar}\npackage.\n\n### First, we will create the data for these examples\n\n```{r all_data}\n\n# Generate example data with high negative skewness\nset.seed(123)\n\n# Parameters\nn_patients \u003c- 10000  # Total number of patients\n\n# Generate survival probabilities (Ps) using a logistic distribution\nPs \u003c- plogis(rnorm(n_patients, mean = 2, sd = 1.5))  # Skewed towards higher values\n\n# Simulate survival outcomes based on Ps\nsurvival_outcomes \u003c- rbinom(n_patients, size = 1, prob = Ps)\n\n# Create data frame\ndata \u003c- data.frame(Ps = Ps, survival = survival_outcomes) |\u003e\ndplyr::mutate(death = dplyr::if_else(survival == 1, 0, 1))\n\n\n```\n\n### The W-Score!\n\n```{r w_score}\n\n# Calculate trauma performance (W, M, Z scores)\ntrauma_performance(data, Ps_col = Ps, outcome_col = death)\n\n```\n\n## 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)\n\nThe M and Z scores are calculated using methods defined in the\n[literature](https://journals.lww.com/jtrauma/abstract/1978/10000/a_method_for_comparing_survival_of_burn_patients.3.aspx)\nmay not be meaningful if your the distribution of the probability of survival\nmeasure is not similar enough to the Major Trauma Outcomes Study distribution.\n{traumar} provides a way to check this in your data analysis script, or even\nfrom the console.  The `trauma_performance()` function does this under the hood\nfor you, so you can get a read out of how much confidence you can put into the Z\nscore.\n\n```{r trauma_case_mix}\n\n# Compare the current case mix with the MTOS case mix\ntrauma_case_mix(data, Ps_col = Ps, outcome_col = death)\n\n```\n\n## The Relative Mortality Metric\n\nNapoli et al.(2017) published methods for calculating a measure of trauma center\n(or system) performance while overcoming a problem with the W-Score and the\nTRISS methodology.  Given that the majority of patients seen at trauma centers\nwill have a probability of survival over 90%, estimating performance based on\nthe W-Score may only indicate how well a center performed with lower acuity\npatients.  Using Napoli et al. (2017), it is possible to calculate a score that\nis similar to the W-Score in its interpretability, but deals with the negatively\nskewed probability of survival problem by creating non-linear bins of score\nranges, and then weighting a score based on the nature of those bins.  The\nRelative Mortality Metric (RMM) has a scale from -1 to 1.\n \n * An RMM of 0 indicates that the observed mortality aligns with the expected\nnational benchmark across all acuity levels.\n * An RMM greater than 0 indicates better-than-expected performance, where\nthe center is outperforming the national benchmark.\n * An RMM less than 0 indicates under-performance, where the center’s observed\nmortality is higher than the expected benchmark.\n\n## Non-Linear Binning Algorithm\n\nAn important part of the approach Napoli et al. (2017) took was to modify the\nM-Score approach of looking at linear bins of the probability of survival\ndistribution, and make it non-linear.  The {traumar} package does this for you\nusing Dr. Napoli's method:\n\n``` {r non_linear}\n\n# Apply the nonlinear_bins function\nresults \u003c- nonlinear_bins(data = data,\n                         Ps_col = Ps,\n                         outcome_col = survival,\n                         divisor1 = 4,\n                         divisor2 = 4,\n                         threshold_1 = 0.9,\n                         threshold_2 = 0.99)\n\n# View intervals created by the algorithm\nresults$intervals\n\n# View the bin statistics\nresults$bin_stats\n\n\n```\n\n## The RMM function\n\nThe RMM is sensitive to higher acuity patients, meaning that if a trauma center\nstruggles with these patients, it will be reflected in the RMM. In contrast, the\nW-Score may mask declines in performance due to the influence of lower acuity\npatients via the MTOS Distribution. The {traumar} package automates RMM\ncalculation as a single score using the nonlinear binning method from Napoli et\nal. (2017). The `rmm()` and `rm_bin_summary()` functions internally call\n`nonlinear_bins()` to generate the non-linear binning process. The function uses \na bootstrap process with `n_samples` repetitions to simulate an RMM distribution and\nestimate 95% confidence intervals. The RMM, along with corresponding\nconfidence intervals, are provided for the population in `data`, as well.\n\n```{r rmm}\n\n# Example usage of the `rmm()` function\nrmm(data = data,\n    Ps_col = Ps,\n    outcome_col = survival,\n    n_samples = 250,\n    Divisor1 = 4,\n    Divisor2 = 4\n    )\n\n# Pivoting can be helpful at times\nrmm(\n  data = data,\n  Ps_col = Ps,\n  outcome_col = survival,\n  n_samples = 250,\n  Divisor1 = 4,\n  Divisor2 = 4,\n  pivot = TRUE\n)\n\n# RMM calculated by non-linear bin range\n# `rm_bin_summary()` function\nrm_bin_summary(data = data,\n               Ps_col = Ps,\n               outcome_col = survival,\n               Divisor1 = 4,\n               Divisor2 = 4,\n               n_samples = 250\n               )\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbemts-hhs%2Ftraumar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbemts-hhs%2Ftraumar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbemts-hhs%2Ftraumar/lists"}