Audit whether an algorithm's area risk ranking matches realised outcomes
Source:R/frns_predpol.R
morie_predpol_calibration_audit.RdRanks areas by predicted risk and by realised outcome rate (rank 1 =
highest), forms rank_gap = outcome_rank - risk_rank per area
(positive = over-predicted), and averages the gap within each group.
A Spearman correlation summarises overall calibration.
Value
A named list: value (worst per-group mean gap), spearman,
spearman_pvalue, group_rank_gap, worst_group, rank_gap,
warnings, interpretation.
Examples
res <- morie_predpol_calibration_audit(
areas = c("d1", "d2", "d3", "d4", "d5", "d6"),
mean_risk = c(90, 80, 70, 30, 20, 10),
outcome_rate = c(10, 20, 30, 70, 80, 90),
group = c("X", "X", "X", "Y", "Y", "Y")
)
res$group_rank_gap$X # 3 (group X over-predicted)
#> [1] 3
res$spearman # -1 (perfectly miscalibrated)
#> [1] -1