Subgroup monitoring¶
A model can perform well on average and poorly for a specific group of
patients, sites or devices. SubgroupMonitor runs one anytime-valid test
per subgroup and controls the overall error.
Metrics¶
Every metric is the mean of a binary outcome over an eligible set of cases.
| Metric | Eligible cases | Outcome | Alarm direction |
|---|---|---|---|
sensitivity |
y_true == 1 |
y_pred == 1 |
too low |
specificity |
y_true == 0 |
y_pred == 0 |
too low |
ppv |
y_pred == 1 |
y_true == 1 |
too low |
npv |
y_pred == 0 |
y_true == 0 |
too low |
accuracy |
all | y_true == y_pred |
too low |
error_rate |
all | y_true != y_pred |
too high |
false_negative_rate |
y_true == 1 |
y_pred == 0 |
too high |
false_positive_rate |
y_true == 0 |
y_pred == 1 |
too high |
Declaring groups¶
All groups must be declared when the monitor is created. The multiplicity correction depends on the number of groups, and allowing new groups to appear later would invalidate it.
monitor = aw.SubgroupMonitor(
metric="sensitivity",
target=0.90,
groups=["age<40", "age40-65", "age>65"],
alpha=0.05,
)
Multiplicity control¶
Two complementary guarantees are available.
Bonferroni alarms (default). Each group is tested at level \(\alpha / K\). By Ville's inequality and the union bound, the probability that any group raises a false alarm at any time is at most \(\alpha\). This is the right guarantee for alarms that trigger corrective action.
e-BH discoveries. monitor.ebh_discoveries() applies the
e-Benjamini-Hochberg procedure to the current e-values. It controls the
false discovery rate at the time of the call under any dependence between
groups and is less conservative when many groups are monitored. It is well
suited to periodic reviews.
Status and intervals¶
monitor.status() returns one SubgroupStatus per group with the number of
cases, the estimate, a confidence sequence at the per-group level, the
current e-value and whether the group has alarmed.
Streaming¶
update may be called with batches of any size, including single cases.
Processing a stream in batches gives exactly the same result as processing
it at once.