Classify a window summary on the SPI and the NPAFP rate
Source:R/spi_rolling.R
spi_window_classify.RdSets the conventional non-polio AFP rate against its target and the SPI
against its threshold, for a spi_window_summary() result.
The rate has the observed count over the window as numerator and
pop_u15 / rate_multiplier as denominator. It is not annualised by
default, so it is a yearly rate when the window covers 12 months. With
annualise = TRUE the same ratio is multiplied by months_per_year and
divided by months. A unit meets the rate target when the rate is at or
above rate_target.
A unit is flagged by the SPI, meaning low relative AFP reporting, when
spi_median is below index_threshold and the upper bound spi_q95 is
below 1, so the whole 90% interval sits below the national level. A unit
whose expected_total is below min_expected, or whose SPI is missing,
carries too little information and is left unclassified (NA).
This relates to spi_compare_npafp() as follows. With
spi_rule = "interval", spi_compare_npafp() flags the SPI by the same
rule, but it takes a district-year spi_index() or spi_simple() result,
computes the rate as count / population x multiplier from a population
table, classifies every district-year without a min_expected rule, uses
the labels "Neither below", "SPI below threshold only", "NPAFP below
target only" and "Both below", and adds agreement statistics.
spi_window_classify() works on one rolling window, leaves low-information
units unclassified, and returns the classification column by column.
Arguments
- summary
A
spi_window_summary()result.- rate_target
Numeric. NPAFP rate target per
rate_multiplier. Default: 3.- index_threshold
Numeric. SPI below which a unit can be flagged. Default: 0.8.
- min_expected
Numeric. Smallest posterior median expected count at which a unit is classified. Default: 1.
- rate_multiplier
Numeric. Population scale of the rate. Default: 100000.
- annualise
Logical. Scale the rate to
months_per_year. Default:FALSE.- months_per_year
Numeric. Months the rate is annualised to when
annualise = TRUE. Default: 12.- agreement_levels
Character, length 4. Labels for: both pass, both flag, rate passes and SPI flags, rate flags and SPI passes. Default:
c("both_pass", "both_flag", "spi_only", "rate_only").- focus_levels
Character, length 2. Labels for units that meet the rate target but are flagged by the SPI, and for every other classified unit. Default:
c("focus", "other").
Value
summary with npafp_rate, readable, rate_pass, ci_below,
index_pass, agreement (factor) and focus_status (factor) added.
See also
Other spi rolling window functions:
spi_rolling_index(),
spi_window_summary()
Examples
summary <- tibble::tibble(
observed = c(3, 3), pop_u15 = 1e5, months = 12L,
expected_total = 5, spi_median = c(0.9, 0.7), spi_q95 = c(1.1, 0.9)
)
spi_window_classify(summary)
#> # A tibble: 2 × 13
#> observed pop_u15 months expected_total spi_median spi_q95 npafp_rate readable
#> <dbl> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <lgl>
#> 1 3 100000 12 5 0.9 1.1 3 TRUE
#> 2 3 100000 12 5 0.7 0.9 3 TRUE
#> # ℹ 5 more variables: rate_pass <lgl>, ci_below <lgl>, index_pass <lgl>,
#> # agreement <fct>, focus_status <fct>