When outcome-label accuracy differs between groups or periods, correct each group’s observed rate under its own supported error model before comparing rates.
Differential outcome-label error in group contrasts
Identify the route by which error differs
A routing policy may add a timestamp event that improves breach detection only in treated branches. Alternatively, a logging outage may miss late tickets in one branch. Either mechanism can change sensitivity or specificity at the same time as treatment. A raw difference in production flags then mixes the outcome difference with measurement differences. The validation sample must cover the comparison groups and relevant dates.
Correct cells before subtracting
Apply the binary-rate inversion separately to treated and comparison groups, using accuracy estimates for each group. The example has observed rates 0.12 and 0.18. Under the stated group-specific sensitivity and specificity, the corrected gap is much smaller than the raw -0.06 rate-point gap. This does not prove which gap is causal; it illustrates how a measured contrast changes under explicit error assumptions. The rate correction gives the formula.
Do not assume error always biases toward zero
The direction depends on outcome prevalence and the pattern of false positives and false negatives across groups. Better recording in the treated group can make a true improvement look smaller or even reverse its apparent sign. A single pooled sensitivity and specificity pair may hide that mechanism. An audit must compare accuracy estimates with denominators and uncertainty, not just inspect the overall classification score.
Keep causal design separate
Correcting labels does not solve confounding, spillovers, selection into treatment or different untreated trends. A before/after or treated/control contrast still needs its own identification argument. If the policy itself changes the meaning of eligible ticket, even group-specific sensitivity and specificity may not restore a common estimand. The rollout design addresses time and group comparison assumptions.
Report unsupported cells honestly
If the reference audit contains no comparison-group breaches, sensitivity for that group cannot be estimated. Do not borrow the treated-group rate silently. One can show scenario values with explicit assumptions, collect more adjudications or decline to correct the contrast. The assumption grid makes scenario dependence visible.
Implementation
def corrected_rate(observed, sensitivity, specificity):
denominator = sensitivity + specificity - 1
if not 0 <= observed <= 1 or not 0 <= sensitivity <= 1 or not 0 <= specificity <= 1:
raise ValueError("invalid probability")
if denominator <= 0:
raise ValueError("error process cannot be inverted")
answer = (observed + specificity - 1) / denominator
if not 0 <= answer <= 1:
raise ValueError("incompatible error assumptions")
return answer
treated_observed = .12
comparison_observed = .18
treated_corrected = corrected_rate(treated_observed, .84, .98)
comparison_corrected = corrected_rate(comparison_observed, .94, .95)
raw_gap = treated_observed - comparison_observed
adjusted_gap = treated_corrected - comparison_corrected
assert abs(raw_gap - (-.06)) < 1e-12
assert adjusted_gap < 0 and abs(adjusted_gap) < abs(raw_gap)Performance and operating cost
For G groups, independent point corrections cost O(G) time and O(G) output space. Group-by-period validation and uncertainty propagation may need many adjudicated records; more production rows do not replace missing reference labels.
Common Mistakes
- Do not assume nondifferential error merely because the same flag name appears in both groups.
- Do not claim the corrected contrast is causal without a valid comparison design.
- Do not borrow accuracy estimates across unsupported groups without stating the assumption.
