Skip to contents

Computes ES performance for each site with a sample in the reporting window. The enterovirus share, poliovirus share, standard and minimum-sample rule are defined as in calc_es_district_performance(), with the site as the unit.

Usage

calc_es_site_performance(
  samples,
  as_of = Sys.Date(),
  from = NULL,
  to = 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",
  regularity_breaks = c(75, 100),
  regularity_labels = c("Fewer than 3 in 4 months", "3 in 4 months or more",
    "Every month"),
  window_months = 12L,
  resolved_min = 0.8,
  settle_months = 3L,
  digits = 1L,
  cols = list()
)

Arguments

samples

Cleaned environmental samples, one row per sample, as returned by clean_es().

as_of

The reporting date, as a Date or a string that as.Date() reads. Defaults to Sys.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 from samples and as_of with es_reporting_window(), using window_months, resolved_min and settle_months.

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".

regularity_breaks

Increasing lower bounds, in per cent, of each band after the first. Default c(75, 100).

regularity_labels

Band labels, one more than regularity_breaks. Default c("Fewer than 3 in 4 months", "3 in 4 months or more", "Every month").

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_min is taken as final. Default 3.

digits

Decimal places to round percentages to, or NULL for no rounding. Default 1. Regularity is banded after rounding.

cols

Named list overriding the default column names, keyed by table, in the same shape as in calc_polio_indicators(), for example list(samples = list(vtype = "virus_type")). The samples defaults are the polished ES columns, with site_name = "site_name", plus vtype = "vtype", site_guid = "site_guid", longitude = "site_x_coordinate", latitude = "site_y_coordinate" and district_key = "adm2_guid", the column samples are counted by district on.

Value

A tibble with one row per site: adm1, adm2, site_name, site_guid, samples, months_sampled, resolved, pending, ev_n, pv_n, x (longitude), y (latitude), ev_pct, pv_pct, first_month, months_open, regularity_pct, regularity_band, province_ev_pct, province_regularity_pct, province_sites, ev_state and ev_meets_standard. Every _pct column is on a scale of 0 to 100.

Details

  • Site regularity (regularity_pct): months in the window with at least one sample (months_sampled) over the months in the window the site was open (months_open), times 100. A site is open from the month of its first sample on or before as_of, so a site opened inside the window is held only to the months since. The share is banded by regularity_breaks into regularity_band.

  • Province pooling: province_ev_pct and province_regularity_pct pool the counts of every site in the province, rather than averaging the site percentages, and province_sites counts the sites.

Rows are sorted by ev_pct, lowest first.

Examples

es <- tibble::tibble(
  adm1 = "P1", adm2 = "D1", site_name = "Site A", site_guid = "S1",
  site_x_coordinate = 65.7, site_y_coordinate = 31.6,
  collection_date = as.Date("2024-01-10") + c(0, 31, 91, 121, 152),
  classification_all = "DONE",
  vtype = c("NPEV", NA, "NPEV", "NPEV", NA)
)
calc_es_site_performance(es, as_of = as.Date("2024-07-15"), window_months = 6)
#> # A tibble: 1 × 23
#>   adm1  adm2  site_name site_guid samples months_sampled resolved pending  ev_n
#>   <chr> <chr> <chr>     <chr>       <int>          <int>    <int>   <int> <int>
#> 1 P1    D1    Site A    S1              5              5        5       0     3
#> # ℹ 14 more variables: pv_n <int>, x <dbl>, y <dbl>, ev_pct <dbl>,
#> #   pv_pct <dbl>, first_month <date>, months_open <int>, regularity_pct <dbl>,
#> #   regularity_band <fct>, province_ev_pct <dbl>,
#> #   province_regularity_pct <dbl>, province_sites <int>, ev_state <fct>,
#> #   ev_meets_standard <lgl>