Skip to contents

Maps the NPAFP rate, SPI, and their agreement for one year:

  • Panel A – conventional NPAFP rate per 100,000 under-15 person-years, grouped into the reporting bands (<1, 1-2, 2-3, 3-6, 6-12, 12-24, >=24). Values below the selected NPAFP target are drawn on the red end of the palette.

  • Panel B – SPI (the posterior median for the model-based SPI), categorised on breaks approximately symmetric on the log scale around the reference of 1 (default -Inf, 0.5, 0.75, 1, 1.33, 2, Inf). Bins at or below the SPI threshold are warm; the rest are cool.

  • Panel C – the SPI and NPAFP category of each district (Neither below, Both below, SPI below threshold only, NPAFP below target only).

The panels are composed via patchwork so the returned object plots as a single figure but each panel is a full ggplot you can extract or restyle.

The maps keep their geographic aspect ratio. Choose image dimensions that match the boundaries to limit empty space. For a wide region, try a 3:1 width-to-height ratio, such as ggsave(width = 15, height = 5). A region that is taller than it is wide needs a taller image.

Usage

spi_compare_npafp_maps(
  comparison,
  boundaries,
  year = NULL,
  spi_threshold = NULL,
  npafp_target = NULL,
  npafp_breaks = c(-Inf, 1, 2, 3, 6, 12, 24, Inf),
  spi_breaks = c(-Inf, 0.5, 0.75, 1, 1.33, 2, Inf),
  id_col = NULL,
  titles = NULL,
  year_label = NULL,
  provinces = TRUE
)

Arguments

comparison

A spi_compare_npafp() result. $district_year must contain year, npafp_rate, spi_median, and category.

boundaries

sf object with the district id column matching comparison$id_col and a POLYGON geometry column.

year

Integer. Which year to display. Defaults to the maximum year in the comparison table.

spi_threshold, npafp_target

Numeric cuts used in the panel subtitles. If NULL (default) they are pulled from comparison$thresholds.

npafp_breaks, spi_breaks

Numeric break vectors used for the categorical fills. Defaults match the paper.

id_col

Character. Name of the district id column in boundaries. Inferred from comparison$id_col if NULL.

titles

Optional character vector of length 3 to override the default panel titles.

year_label

Character. What to call the displayed year in the panel titles. Defaults to the plain year (e.g. "2023"). Pass sprintf("year T-1: %d", year) when displaying this map beside detections from the following year.

provinces

Logical. Add province outlines in dark grey over the district maps. Default TRUE. The outlines are formed by merging district polygons. If district edges do not align, this can leave small gaps or strips; set FALSE to omit the province outlines.

Value

A patchwork object plotting the three panels side by side.

Examples

if (FALSE) { # \dontrun{
spi_dy <- spi_index(
  cases = synth_surveillance$cases,
  population = synth_surveillance$population,
  adjacency = synth_surveillance$boundaries,
  first_assessment = 2018,
  id_col = "adm2_guid"
)
comparison <- spi_compare_npafp(
  spi = spi_dy,
  cases = synth_surveillance$cases,
  population = synth_surveillance$population,
  boundaries = synth_surveillance$boundaries
)
spi_compare_npafp_maps(
  comparison, synth_surveillance$boundaries, year = 2023
)
} # }