| Type: | Package |
| Title: | Bayesian Early-Warning Risk Surveillance for Healthcare Performance Monitoring |
| Version: | 0.1.1 |
| Description: | Provides Bayesian early-warning surveillance methods for monitoring healthcare performance and patient safety outcomes. The package draws on risk-adjusted monitoring frameworks developed by Steiner et al. (2000) <doi:10.1093/biostatistics/1.4.441>, Spiegelhalter et al. (2003) <doi:10.1002/sim.1546>, Cook et al. (2011) <doi:10.1136/bmjqs.2008.031831>, and Neuburger et al. (2017) <doi:10.1136/bmjqs-2016-005511>. The package implements Bayesian predictive modelling, risk-adjusted monitoring, early-warning signal detection, and graphical tools for continuous quality improvement and healthcare performance assessment. |
| License: | GPL-3 |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| Depends: | R (≥ 4.2.0) |
| Imports: | ggplot2, pROC |
| Suggests: | testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| URL: | https://github.com/zerish12/bewrs |
| BugReports: | https://github.com/zerish12/bewrs/issues |
| NeedsCompilation: | no |
| Packaged: | 2026-06-20 15:22:09 UTC; muhammadzahirkhan |
| Author: | Muhammad Zahir Khan [aut, cre] |
| Maintainer: | Muhammad Zahir Khan <zahirstat007@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-06-24 10:00:07 UTC |
Compute Dynamic BEWRS
Description
Computes the Bayesian Dynamic Early-Warning Risk Score using current posterior underperformance probability, persistence, and deterioration.
Usage
compute_dynamic_bewrs(
up,
persistence,
deterioration,
alpha = 0,
beta_up = 1,
beta_persistence = 1,
beta_deterioration = 1
)
Arguments
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. |
Value
Numeric vector of Dynamic BEWRS probabilities.
Examples
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 Expected Value of Intervention
Description
Computes the Expected Value of Intervention (EVI) as the reduction in expected loss from no action to the selected intervention.
Usage
compute_evi(loss_no_action, loss_intervention)
Arguments
loss_no_action |
Numeric vector of expected loss under no action. |
loss_intervention |
Numeric vector of expected loss under intervention. |
Value
Numeric vector of EVI values.
Examples
compute_evi(c(10, 5, 2), c(7, 4, 3))
Select optimal intervention
Description
Selects the intervention with the lowest expected loss.
Usage
optimal_intervention(loss_matrix)
Arguments
loss_matrix |
Numeric matrix or data.frame of expected losses. Rows represent observational units and columns represent intervention options. |
Value
A data.frame containing optimal action and minimum expected loss.
Examples
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
Description
Plot calibration curve
Usage
plot_calibration(observed, predicted, groups = 10)
Arguments
observed |
Binary observed outcome, coded 0/1. |
predicted |
Predicted probabilities. |
groups |
Number of quantile groups. |
Value
A ggplot object.
Plot risk group event rates
Description
Plot risk group event rates
Usage
plot_risk_groups(observed, risk_group)
Arguments
observed |
Binary observed outcome, coded 0/1. |
risk_group |
Ordered risk group factor. |
Value
A ggplot object.
Stratify Dynamic BEWRS risk
Description
Classifies risk probabilities into Low, Watchlist, High, and Critical groups.
Usage
risk_stratify(risk, cutoffs = c(0.25, 0.5, 0.75))
Arguments
risk |
Numeric vector of predicted risk probabilities. |
cutoffs |
Numeric vector of three cutoffs. Default is c(0.25, 0.50, 0.75). |
Value
Ordered factor of risk categories.
Examples
risk_stratify(c(0.1, 0.4, 0.6, 0.9))
Validate BEWRS predictions
Description
Computes AUC, Brier score, calibration intercept, and calibration slope.
Usage
validate_bewrs(observed, predicted)
Arguments
observed |
Binary vector of observed outcomes, coded 0/1. |
predicted |
Numeric vector of predicted probabilities. |
Value
A data.frame containing validation metrics.
Examples
validate_bewrs(c(0, 1, 1, 0), c(0.1, 0.8, 0.7, 0.3))