
Environmental surveillance performance by district
Source:R/es_performance.R
calc_es_district_performance.RdComputes ES performance for each district over the reporting window.
Usage
calc_es_district_performance(
samples,
as_of = Sys.Date(),
from = NULL,
to = NULL,
admin_units = NULL,
guid_lookup = NULL,
pv_pattern = "^WPV|^cVDPV|^VDPV|^aVDPV|^iVDPV",
ev_threshold = 50,
min_samples = 5L,
measured_label = "Measured",
thin_label = "Too few samples",
absent_label = "No ES site",
window_months = 12L,
resolved_min = 0.8,
settle_months = 3L,
digits = NULL,
cols = list()
)Arguments
- samples
Cleaned environmental samples, one row per sample, as returned by
clean_es().- as_of
The reporting date, as a
Dateor a string thatas.Date()reads. Defaults toSys.Date(). Samples collected after it, or with no collection date, are left out.- from, to
First and last collection date of the reporting window. When both are
NULL(the default) the window is computed fromsamplesandas_ofwithes_reporting_window(), usingwindow_months,resolved_minandsettle_months.- admin_units
Optional table of every district to report, with the columns named by
cols$samples$adm1,cols$samples$adm2andcols$samples$adm2_guid. A district with no sample in the window is kept with zero counts.NULL(default) reports only districts with a sample in the window.- guid_lookup
Optional table with columns
fromandtothat maps a retired district key to its current key. Keys not listed are kept.- pv_pattern
Regular expression a virus type must match to count as a poliovirus. Default
"^WPV|^cVDPV|^VDPV|^aVDPV|^iVDPV", wild and vaccine-derived poliovirus, not Sabin or NPEV.- ev_threshold
Enterovirus share, in per cent, at or above which a unit meets the standard. Default
50.- min_samples
Fewest resolved samples for a percentage to be measured. Default
5.- measured_label, thin_label, absent_label
Labels for the three states. Defaults
"Measured","Too few samples"and"No ES site".- window_months
Number of collection months in the window. Default
12.- resolved_min
Share of a month's samples that must be resolved for the month to count as complete. Default
0.80.- settle_months
Number of months after which a month still below
resolved_minis taken as final. Default3.- digits
Decimal places to round percentages to, or
NULL(default for districts) for no rounding.- cols
Named list overriding the default column names, keyed by table, in the same shape as in
calc_polio_indicators(), for examplelist(samples = list(vtype = "virus_type")). Thesamplesdefaults are the polished ES columns, withsite_name = "site_name", plusvtype = "vtype",site_guid = "site_guid",longitude = "site_x_coordinate",latitude = "site_y_coordinate"anddistrict_key = "adm2_guid", the column samples are counted by district on.
Value
A tibble with one row per district: level ("adm2"), guid,
name, the province name adm1, sites, samples, resolved,
pending, ev_n, pv_n, ev_pct, pv_pct, ev_state and
ev_meets_standard. ev_pct and pv_pct are on a scale of 0 to 100.
Details
Enterovirus share (
ev_pct): samples with any virus type recorded (ev_n, a non-polio enterovirus or any poliovirus) over resolved samples (resolved), times 100. The GPEI standard is 50 per cent or more (ev_threshold). This differs from theev_rateindicator incalc_polio_indicators(), which divides by all samples, and fromsites_with_entero_pct, which counts a site as meeting the standard above 49 per cent. Here samples still at the laboratory are left out of the denominator, and the standard is met at 50 per cent or more.Poliovirus share (
pv_pct): samples whose virus type matchespv_pattern(pv_n) over resolved samples, times 100. No threshold.Minimum-sample rule (
ev_state): a district with fewer thanmin_samplesresolved samples is marked as having too few, and one with none as absent. Seees_sample_state().
A percentage is NA when the district has no resolved samples. Samples are
counted by district on district_key, so a retired district GUID can be
repaired before the call (supply the repaired key as a column and point
cols$samples$district_key at it) or through guid_lookup.
Examples
es <- tibble::tibble(
adm1 = "P1", adm2 = "D1", adm2_guid = "G1", site_guid = "S1",
collection_date = as.Date("2024-01-01") + c(0, 31, 60, 91, 121, 152),
classification_all = "DONE",
vtype = c("NPEV", NA, "NPEV", "cVDPV2", NA, "NPEV")
)
calc_es_district_performance(es, as_of = as.Date("2024-07-15"), window_months = 6)
#> # A tibble: 1 × 14
#> level guid name adm1 sites samples resolved pending ev_n pv_n ev_pct
#> <chr> <chr> <chr> <chr> <int> <int> <int> <int> <int> <int> <dbl>
#> 1 adm2 G1 D1 P1 1 6 6 0 4 1 66.7
#> # ℹ 3 more variables: pv_pct <dbl>, ev_state <fct>, ev_meets_standard <lgl>