Skip to contents

Builds an invented geography of countries, provinces and districts, one row per district, that the other simulators place cases, samples and population on. Names follow the pattern PROVINCE 01 and DISTRICT 01-03, where the district name carries its province number. Country codes come from the ISO 3166 range reserved for user-assigned codes, so no code belongs to a real country. GUIDs are drawn at random.

Usage

simulate_admin_frame(
  n_countries = 1L,
  n_provinces = 4L,
  n_districts = 6L,
  u15_pop_range = c(20000, 2e+05),
  iso3_codes = NULL,
  country_prefix = "COUNTRY",
  province_prefix = "PROVINCE",
  district_prefix = "DISTRICT",
  lon_range = c(-30, -20),
  lat_range = c(-30, -20),
  seed = 1L
)

Arguments

n_countries

Number of countries. Default 1L.

n_provinces

Number of provinces in each country. Default 4L.

n_districts

Number of districts in each province. Default 6L.

u15_pop_range

Lower and upper bound of the under-15 population of a district, drawn uniformly on the log scale. Default c(20000, 200000).

iso3_codes

Three-letter country codes, one for each country. Default NULL, which gives QZA, QZB and so on from the user-assigned range.

country_prefix, province_prefix, district_prefix

Words that start each country, province and district name. Defaults "COUNTRY", "PROVINCE" and "DISTRICT".

lon_range, lat_range

Bounds of the box district centres are drawn in, in decimal degrees. Defaults c(-30, -20) and c(-30, -20).

seed

Seed for the random draws. Default 1L. The caller's random state is left as it was.

Value

A tibble with one row per district and the columns country_iso3code, adm0, adm0_guid, adm1, adm1_guid, adm1_code, adm2, adm2_guid, adm2_code, center_lon, center_lat and u15_pop.

Details

Names are upper case by default, as POLIS writes them; pass other prefixes to change that. The column names follow the boundary and population tables read in rise-afg 02_scripts/2c_indicators/2civ_surveillance.R and 02_scripts/2c_indicators/2cxxviii_genetic.R. The adm1_code and adm2_code columns are added here to build identifiers.

District centres are drawn uniformly inside a longitude and latitude box. The default box lies in the open South Atlantic, so no synthetic point falls inside a real country.

Examples

admin <- simulate_admin_frame(n_provinces = 2, n_districts = 3)
admin
#> # A tibble: 6 × 12
#>   country_iso3code adm0      adm0_guid adm1  adm1_guid adm1_code adm2  adm2_guid
#>   <chr>            <chr>     <chr>     <chr> <chr>     <chr>     <chr> <chr>    
#> 1 QZA              COUNTRY … {83601C6… PROV… {8BE0325… P01       DIST… {CB5CBBF…
#> 2 QZA              COUNTRY … {83601C6… PROV… {8BE0325… P01       DIST… {90AA9E9…
#> 3 QZA              COUNTRY … {83601C6… PROV… {8BE0325… P01       DIST… {84CD025…
#> 4 QZA              COUNTRY … {83601C6… PROV… {FD1C15D… P02       DIST… {231F0B6…
#> 5 QZA              COUNTRY … {83601C6… PROV… {FD1C15D… P02       DIST… {9E348F4…
#> 6 QZA              COUNTRY … {83601C6… PROV… {FD1C15D… P02       DIST… {BE47308…
#> # ℹ 4 more variables: adm2_code <chr>, center_lon <dbl>, center_lat <dbl>,
#> #   u15_pop <dbl>