Identify Outlier Units by Month for a Given Indicator
Source:R/1a_checks_outlier.R
list_outlier_units.Rd
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")
)
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')
} # }