| Title: | Bayesian Early-Warning Risk Surveillance for Healthcare Performance Monitoring |
|---|---|
| Description: | Provides tools for Bayesian early-warning risk surveillance in healthcare performance monitoring. The package implements functions for posterior underperformance risk estimation, Dynamic Bayesian Early-Warning Risk Score computation, temporal and external validation, calibration assessment, decision curve analysis, decision-theoretic intervention optimisation, and Expected Value of Intervention analysis. The methodology is motivated by Bayesian hierarchical modelling, healthcare provider profiling, early-warning surveillance, and decision-theoretic resource allocation, including approaches discussed by Gelman et al. (2013), Spiegelhalter (2005) <doi:10.1136/bmj.331.7512.302>, Vickers and Elkin (2006) <doi:10.1177/0272989X06295361>, and Parmigiani and Inoue (2009). |
| Authors: | Muhammad Zahir Khan [aut, cre] |
| Maintainer: | Muhammad Zahir Khan <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-06-25 08:36:47 UTC |
| Source: | https://github.com/zerish12/bewrs |
Computes the Bayesian Dynamic Early-Warning Risk Score using current posterior underperformance probability, persistence, and deterioration.
compute_dynamic_bewrs( up, persistence, deterioration, alpha = 0, beta_up = 1, beta_persistence = 1, beta_deterioration = 1 )compute_dynamic_bewrs( up, persistence, deterioration, alpha = 0, beta_up = 1, beta_persistence = 1, beta_deterioration = 1 )
up |
Numeric vector of posterior underperformance probabilities. |
persistence |
Numeric vector measuring persistence of elevated risk. |
deterioration |
Numeric vector measuring recent deterioration. |
alpha |
Intercept parameter. |
beta_up |
Coefficient for logit-transformed posterior risk. |
beta_persistence |
Coefficient for persistence. |
beta_deterioration |
Coefficient for deterioration. |
Numeric vector of Dynamic BEWRS probabilities.
compute_dynamic_bewrs( up = c(0.2, 0.5, 0.8), persistence = c(0.1, 0.4, 0.7), deterioration = c(0.0, 0.1, 0.2) )compute_dynamic_bewrs( up = c(0.2, 0.5, 0.8), persistence = c(0.1, 0.4, 0.7), deterioration = c(0.0, 0.1, 0.2) )
Computes the Expected Value of Intervention (EVI) as the reduction in expected loss from no action to the selected intervention.
compute_evi(loss_no_action, loss_intervention)compute_evi(loss_no_action, loss_intervention)
loss_no_action |
Numeric vector of expected loss under no action. |
loss_intervention |
Numeric vector of expected loss under intervention. |
Numeric vector of EVI values.
compute_evi(c(10, 5, 2), c(7, 4, 3))compute_evi(c(10, 5, 2), c(7, 4, 3))
Selects the intervention with the lowest expected loss.
optimal_intervention(loss_matrix)optimal_intervention(loss_matrix)
loss_matrix |
Numeric matrix or data.frame of expected losses. Rows represent observational units and columns represent intervention options. |
A data.frame containing optimal action and minimum expected loss.
losses <- data.frame( no_action = c(10, 5, 2), monitor = c(8, 4, 3), review = c(7, 6, 4) ) optimal_intervention(losses)losses <- data.frame( no_action = c(10, 5, 2), monitor = c(8, 4, 3), review = c(7, 6, 4) ) optimal_intervention(losses)
Plot calibration curve
plot_calibration(observed, predicted, groups = 10)plot_calibration(observed, predicted, groups = 10)
observed |
Binary observed outcome, coded 0/1. |
predicted |
Predicted probabilities. |
groups |
Number of quantile groups. |
A ggplot object.
Plot risk group event rates
plot_risk_groups(observed, risk_group)plot_risk_groups(observed, risk_group)
observed |
Binary observed outcome, coded 0/1. |
risk_group |
Ordered risk group factor. |
A ggplot object.
Classifies risk probabilities into Low, Watchlist, High, and Critical groups.
risk_stratify(risk, cutoffs = c(0.25, 0.5, 0.75))risk_stratify(risk, cutoffs = c(0.25, 0.5, 0.75))
risk |
Numeric vector of predicted risk probabilities. |
cutoffs |
Numeric vector of three cutoffs. Default is c(0.25, 0.50, 0.75). |
Ordered factor of risk categories.
risk_stratify(c(0.1, 0.4, 0.6, 0.9))risk_stratify(c(0.1, 0.4, 0.6, 0.9))
Computes AUC, Brier score, calibration intercept, and calibration slope.
validate_bewrs(observed, predicted)validate_bewrs(observed, predicted)
observed |
Binary vector of observed outcomes, coded 0/1. |
predicted |
Numeric vector of predicted probabilities. |
A data.frame containing validation metrics.
validate_bewrs(c(0, 1, 1, 0), c(0.1, 0.8, 0.7, 0.3))validate_bewrs(c(0, 1, 1, 0), c(0.1, 0.8, 0.7, 0.3))