# BayesSurveillance

BayesSurveillance is an R package for Bayesian adaptive surveillance and intervention learning.

## Core workflow

```r
library(BayesSurveillance)

dat <- simulate_surveillance_data(seed = 1)
fit <- fit_bewrs(dat)
risk <- compute_dynamic_bewrs(fit)
peib <- estimate_peib(risk)
policy <- recommend_action(peib)
evaluate_policy(policy)
```

## Adaptive update workflow

```r
old_dat <- simulate_surveillance_data(seed = 1)
new_dat <- simulate_surveillance_data(seed = 2)

updated_policy <- update_policy(old_dat, new_dat)
evaluate_policy(updated_policy)

# Or run the full pipeline directly
policy2 <- adaptive_update(new_dat)
```

## Core methodological idea

The package extends BEWRS from early-warning risk prediction to adaptive intervention learning:

1. Estimate posterior underperformance risk.
2. Convert risk into Dynamic BEWRS using persistence and deterioration.
3. Estimate Provider-specific Expected Intervention Benefit (PEIB).
4. Recommend Bayes-optimal action by expected-loss minimisation.
5. Update the policy as new surveillance data arrive.
