Compares a per-record count – by default the `ROWCOUNT` column [transform_transaction_to_master()] produces – between the RAW and ANON sides.
Arguments
- dat_raw_anon
dataframe of raw_anon form
- target
name of the count column (default `"ROWCOUNT"`)
- row_number
name of the row-number column *before* the RAW_/ANON_ prefixing done by [join_raw_anon_data()] (default: "ROW_NUMBER")
- method
`"log_ratio"` (default), `"absolute"` or `"relative"` (`|a - b| / max(a, b, 1)`, bounded in \[0, 1\])
- generalized
what to do when `target` turns out to hold generalised values on the ANON side: `"stop"` (default), `"warn"` or `"ignore"`. A count published as a band (`"[10,20)"`) is not a number, so this only decides which of the two errors is raised.
- .fn_name
name used in error messages; a function that wraps this one passes its own name so the message points at the function the user actually called
Details
The default `method = "log_ratio"` compares `log1p` of the two counts rather than the counts themselves, because activity counts are heavy tailed: the gap between 2 visits and 7 is strong evidence that these are different people, while the same gap between 200 and 205 is nothing. An absolute difference scores those two situations identically and so spends most of its discriminating power on the few busiest records.
Examples
tran <- create_dummy_transaction_data(people = 20, size = 4)
master <- transform_transaction_to_master(
tran, DYNAMIC_NUM = "NUM_DYNAMIC", STATIC_NUM = "NUM_STATIC"
)
j <- join_raw_anon_data(master, master)
match_greedy(score_count(j, row_number = "ROW_NUMBER"))
#> ANON_ROW_NUMBER RAW_ROW_NUMBER CONFIDENCE RESULT
#> 1 1 1 0.000000 TRUE
#> 2 2 24 0.000000 FALSE
#> 3 3 18 0.000000 FALSE
#> 4 4 2 0.000000 FALSE
#> 5 5 5 0.000000 TRUE
#> 6 6 10 0.000000 FALSE
#> 7 7 7 0.000000 TRUE
#> 8 8 6 0.000000 FALSE
#> 9 9 9 0.000000 TRUE
#> 10 10 6 0.000000 FALSE
#> 11 11 5 0.000000 FALSE
#> 12 13 13 0.000000 TRUE
#> 13 18 19 0.000000 FALSE
#> 14 19 5 0.000000 FALSE
#> 15 24 4 0.000000 FALSE
#> 16 28 28 1.104554 TRUE
#> 17 37 6 0.000000 FALSE
#> 18 51 51 1.160345 TRUE