The small-number problem, named: a rate over a very small population is mostly noise, and on a map it shouts as loudly as a rate over a very large one. This reports which countries' rates you should not trust before you plot them.
Arguments
- data
A country-level frame.
- numerator, denominator
The count and the population it is over (unquoted).
- min_denominator
Denominators below this are flagged.
NULL(default) uses the 10th percentile of the observed denominators, which adapts to the data rather than imposing a threshold that suits one indicator.- rate
An existing rate column (unquoted), if you already computed it. Otherwise the rate is
numerator / denominator.
Value
A tibble of iso3c, numerator, denominator, rate,
expected_se (the Poisson standard error of the rate, \(\sqrt{r/d}\)) and
flagged, sorted with the least reliable first.
"Least reliable" is ordered on the standard error a single event would
imply, \(\sqrt{\max(y, 1)}/d\), which is identical to expected_se for
every row with at least one event. Ordering on expected_se directly put
zero-count rows last, at the reliable end: it is \(\sqrt{y}/d\), which
is exactly 0 when the count is 0, so one country with no events out of
251 people outranked another with one event out of the same 251. Observing
nothing is not evidence of precision. expected_se itself is still the
plain Poisson standard error, 0 and all.
flagged is TRUE for a
denominator below the threshold, FALSE above it or missing, and NA for
every row when no threshold could be computed at all – which is warned
about, and means sum(flagged) is NA rather than a misleading 0.
What to do about it
Three answers, in rough order of preference: smooth_rates() shrinks the
unreliable rates toward the global rate; value_by_alpha_map() leaves them
alone but fades them out; or drop them and say so in the caption. Plotting
them raw and unremarked is the one option that misleads.
References
Roth, R. E., Woodruff, A. W. & Johnson, Z. F. (2010). Value-by-alpha maps: an alternative technique to the cartogram. The Cartographic Journal 47(2), 130-140. doi:10.1179/000870409X12488753453372
Examples
d <- data.frame(
iso3c = c("CHN", "IND", "TUV", "NRU"),
cases = c(50000, 42000, 3, 1),
pop = c(1.41e9, 1.39e9, 11000, 12000)
)
rate_check(d, cases, pop)
#> # A tibble: 4 × 6
#> iso3c numerator denominator rate expected_se flagged
#> <chr> <dbl> <dbl> <dbl> <dbl> <lgl>
#> 1 TUV 3 11000 0.000273 0.000157 TRUE
#> 2 NRU 1 12000 0.0000833 0.0000833 FALSE
#> 3 CHN 50000 1410000000 0.0000355 0.000000159 FALSE
#> 4 IND 42000 1390000000 0.0000302 0.000000147 FALSE
