Skip to contents

Tie-breaking used to keep `RAW_ROW_NUMBER[1]`, i.e. whichever tied candidate happened to come first in the input. That made the reported success rate depend on the row order of a cross join, which is not a property of the data: on a 50-person fixture, reshuffling the input rows moved the rate over [0.02, 0.14] around a mean of 0.058. It also concentrated every success onto the first record of each tie group, which systematically distorts per-record risk even when the overall mean is unaffected. Random tie-breaking makes the estimator unbiased per record and lets the run-to-run spread be measured (see [reid_evaluate()]).

Usage

resolve_min_distance_ties(dat_with_distance, seed = NULL)

Arguments

dat_with_distance

data frame with (at least) RAW_ROW_NUMBER, ANON_ROW_NUMBER and DISTANCE columns

seed

integer seed for the random tie-break, or NULL (default) to use the ambient RNG stream

Value

`dat_with_distance`, filtered down to exactly one row per ANON_ROW_NUMBER (a uniformly chosen minimal-DISTANCE RAW candidate), ordered by ANON_ROW_NUMBER.

Details

Also guards against silently reporting an empty/short result: if DISTANCE is NA for every row, or if some ANON_ROW_NUMBER ends up with zero rows after tie-breaking (which happens when every candidate DISTANCE for that ANON record is NA), this stops with an error instead of quietly shrinking the result (and thus the reported trial count).