Skip to contents

This function summarizes a single immunization indicator by month and administrative level, then applies a Hampel filter (5 × MAD) to flag extreme outliers. It returns a tidy object suitable for plotting or time-series review at subnational levels.

Usage

list_outlier_units(
  .data,
  indicator,
  admin_level = c("adminlevel_1", "district")
)

Arguments

.data

A cd_data object containing monthly health indicator data.

indicator

Character. The name of a single indicator to evaluate for outliers. Must be one of: "opv1", "opv2", "opv3", "penta1", "penta2", "penta3", "measles1", "measles2", "pcv1", "pcv2", "pcv3", "bcg", "rota1", "rota2", "ipv1", "ipv2".

admin_level

Character. The administrative level to summarize by. Options are "adminlevel_1" or "district".

Value

A cd_outlier_list object (a tibble) with the following columns:

  • Grouping columns (adminlevel_1, district, year, month)

  • The selected indicator

  • Median (<indicator>_med)

  • MAD (<indicator>_mad)

  • Outlier flag (<indicator>_outlier5std)

Details

  • Computes monthly means of the specified indicator by administrative unit and time.

  • Calculates median and MAD (Median Absolute Deviation) for outlier detection.

  • Flags outliers when values exceed ±5×MAD from the median.

Examples

if (FALSE) { # \dontrun{
  # Detect monthly outliers in Penta1 at district level
  outliers <- list_outlier_units(cd_data, indicator = "penta1", admin_level = "district")

  # Plot flagged points in a specific region
  plot(outliers, region = "Nakuru")
} # }