Package 'BayesSurveillance'

Title: Bayesian Surveillance Methods for Healthcare Performance Monitoring
Description: Provides Bayesian surveillance methods for prospective monitoring of healthcare performance, patient safety, and clinical quality indicators. The package implements beta-binomial monitoring for binary outcomes, gamma-Poisson monitoring for count outcomes, posterior predictive alert probabilities, risk-adjusted surveillance, early-warning signal rules, simulation tools, and graphical summaries. Methods are motivated by risk-adjusted monitoring and healthcare surveillance frameworks including 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-005667>.
Authors: Muhammad Zahir Khan [aut, cre]
Maintainer: Muhammad Zahir Khan <[email protected]>
License: GPL-3
Version: 0.1.0
Built: 2026-07-12 09:18:28 UTC
Source: https://github.com/zerish12/bayessurveillance

Help Index


Bayesian Alert Probability

Description

Bayesian Alert Probability

Usage

alert_probability(posterior_probability, threshold = 0.95)

Arguments

posterior_probability

Numeric vector of posterior probabilities.

threshold

Alert threshold.

Value

Logical vector indicating alerts.


Approximate Bayes Factor Alert

Description

Approximate Bayes Factor Alert

Usage

bayes_factor_alert(posterior_prob, prior_prob = 0.5, threshold = 3)

Arguments

posterior_prob

Posterior probability of deterioration.

prior_prob

Prior probability of deterioration.

threshold

Bayes factor threshold.

Value

Data frame with Bayes factor and alert.


Bayesian CUSUM Surveillance

Description

Bayesian CUSUM Surveillance

Usage

bayesian_cusum(observed, expected, threshold = 5, reset = TRUE)

Arguments

observed

Observed outcomes.

expected

Expected outcomes.

threshold

CUSUM alert threshold.

reset

Logical; reset CUSUM at zero.

Value

A data frame with Bayesian CUSUM statistics.


Bayesian EWMA Surveillance

Description

Bayesian EWMA Surveillance

Usage

bayesian_ewma(observed, expected, lambda = 0.2, threshold = 3)

Arguments

observed

Observed outcomes.

expected

Expected outcomes.

lambda

EWMA smoothing parameter.

threshold

Alert threshold.

Value

A data frame with EWMA statistics.


Bayesian Funnel Plot Data

Description

Bayesian Funnel Plot Data

Usage

bayesian_funnel_plot(observed, expected, level = 0.95)

Arguments

observed

Observed events.

expected

Expected events.

level

Credible interval level.

Value

A data frame for funnel plot construction.


Bayesian Beta-Binomial Monitoring for Binary Outcomes

Description

Bayesian Beta-Binomial Monitoring for Binary Outcomes

Usage

beta_binomial_monitor(y, n, alpha_prior = 1, beta_prior = 1, threshold = 0.95)

Arguments

y

Number of observed events at each time point.

n

Number of patients/cases at each time point.

alpha_prior

Prior alpha parameter.

beta_prior

Prior beta parameter.

threshold

Alert threshold for posterior probability.

Value

A data frame with posterior estimates and alert status.


Calibration Summary for Surveillance Predictions

Description

Calibration Summary for Surveillance Predictions

Usage

calibration_surveillance(observed, predicted, groups = 10)

Arguments

observed

Binary observed outcomes.

predicted

Predicted risks.

groups

Number of calibration groups.

Value

Calibration table.


Create Research-Quality Surveillance Figures

Description

Saves high-resolution example figures to man/figures.

Usage

create_research_figures(output_dir = "man/figures")

Arguments

output_dir

Directory where figures are saved.

Value

Invisibly returns saved file paths.


Early-Warning Signal Rule

Description

Early-Warning Signal Rule

Usage

early_warning_signal(probability, threshold = 0.95, consecutive = 1)

Arguments

probability

Posterior or predictive probability.

threshold

Alert threshold.

consecutive

Number of consecutive signals required.

Value

Logical vector indicating alerts.


Calculate Expected Events

Description

Calculate Expected Events

Usage

expected_events(risk, group = NULL)

Arguments

risk

Predicted patient-level risks.

group

Optional grouping variable.

Value

Expected event totals.


Observed Minus Expected Statistic

Description

Observed Minus Expected Statistic

Usage

o_minus_e(observed, expected)

Arguments

observed

Observed outcomes.

expected

Expected outcomes.

Value

Data frame with O-E statistics.


Plot Surveillance Results

Description

Plot Surveillance Results

Usage

plot_surveillance(data, y = "posterior_mean")

Arguments

data

Data frame returned by a surveillance function.

y

Column name to plot.

Value

A ggplot object.


Bayesian Gamma-Poisson Monitoring for Count Outcomes

Description

Bayesian Gamma-Poisson Monitoring for Count Outcomes

Usage

poisson_gamma_monitor(
  y,
  exposure,
  shape_prior = 1,
  rate_prior = 1,
  threshold = 0.95
)

Arguments

y

Observed counts.

exposure

Exposure or expected counts.

shape_prior

Prior gamma shape.

rate_prior

Prior gamma rate.

threshold

Alert threshold.

Value

A data frame with posterior rate estimates and alerts.


Posterior Predictive Probability

Description

Posterior Predictive Probability

Usage

posterior_predictive(
  observed,
  predicted,
  sd_pred,
  direction = c("higher", "lower")
)

Arguments

observed

Observed value.

predicted

Predicted or expected value.

sd_pred

Predictive standard deviation.

direction

Direction of concern: "higher" or "lower".

Value

Posterior predictive tail probability.


Risk-Adjusted CUSUM

Description

Risk-Adjusted CUSUM

Usage

risk_adjusted_cusum(observed, expected, threshold = 5)

Arguments

observed

Observed outcomes.

expected

Expected outcomes.

threshold

Alert threshold.

Value

Risk-adjusted CUSUM results.


Risk-Adjusted EWMA

Description

Risk-Adjusted EWMA

Usage

risk_adjusted_ewma(observed, expected, lambda = 0.2, threshold = 3)

Arguments

observed

Observed outcomes.

expected

Expected outcomes.

lambda

EWMA smoothing parameter.

threshold

Alert threshold.

Value

Risk-adjusted EWMA results.


Risk-Adjusted Observed Minus Expected Monitoring

Description

Risk-Adjusted Observed Minus Expected Monitoring

Usage

risk_adjusted_monitor(observed, expected, threshold = 3)

Arguments

observed

Observed outcomes.

expected

Expected outcomes.

threshold

Alert threshold for cumulative O-E statistic.

Value

A data frame with O-E statistics and alerts.


ROC Evaluation for Surveillance Alerts

Description

ROC Evaluation for Surveillance Alerts

Usage

roc_surveillance(truth, score)

Arguments

truth

Binary true outcome.

score

Numeric risk or alert score.

Value

A list containing ROC object and AUC.


Simulate Healthcare Surveillance Data

Description

Simulate Healthcare Surveillance Data

Usage

simulate_surveillance_data(
  n_time = 50,
  patients_per_time = 100,
  baseline_risk = 0.05,
  change_point = NULL,
  risk_multiplier = 1.5
)

Arguments

n_time

Number of time points.

patients_per_time

Number of patients per time point.

baseline_risk

Baseline event probability.

change_point

Time point where risk changes.

risk_multiplier

Risk multiplier after change point.

Value

A simulated surveillance data frame.


Summarise BayesSurveillance Results

Description

Summarise BayesSurveillance Results

Usage

## S3 method for class 'BayesSurveillance'
summary(object, ...)

Arguments

object

A surveillance result data frame.

...

Additional arguments.

Value

Summary information.