my_frame <- readRDS("data/rwa_eas.rds") |>
mutate(unit = ea_id, domain = district, residence = urban_rural,
key_1 = sector, key_2 = cell, key_3 = village,
households, .keep = "none")
head(my_frame)
#> households unit domain residence key_1 key_2
#> 1 93 5701010001 Bugesera Rural Gashora Biryogo
#> 2 111 5701010301 Bugesera Rural Gashora Biryogo
#> 3 72 5701010401 Bugesera Rural Gashora Biryogo
#> 4 216 5701010501 Bugesera Rural Gashora Biryogo
#> 5 179 5701010701 Bugesera Rural Gashora Biryogo
#> 6 134 5701020101 Bugesera Rural Gashora Kabuye
#> key_3
#> 1 Gashora refugee Camp
#> 2 Buhoro
#> 3 Gihanama
#> 4 Kagarama
#> 5 Karutete
#> 6 Bidudu
## Checks of the frame
c(units = nrow(my_frame), unique_codes = n_distinct(my_frame$unit),
zero_size = sum(my_frame$households <= 0),
below_take = sum(my_frame$households < 25))
#> units unique_codes zero_size below_take
#> 24073 24073 0 105
shared_keys <- my_frame |>
summarise(domains = n_distinct(domain), .by = key_1) |>
filter(domains > 1) |>
arrange(desc(domains), key_1)
head(shared_keys)
#> key_1 domains
#> 1 Remera 4
#> 2 Kageyo 3
#> 3 Karama 3
#> 4 Muganza 3
#> 5 Murambi 3
#> 6 Ngoma 329 Bring your own survey
The four designs of this part use frames and reports of four countries. A planner in another office has a frame of their own and the report of their own last round. This chapter says what those two need to contain for the methods of the book to apply, runs the first steps on a frame the book has not used for that purpose, and shows how to build the synthetic population a virtual survey needs.
29.1 Two tables
Everything the book does starts from two tables.
The frame has one row per area unit, an EA or a pre-EA, with these columns.
| Column | Content | Used for |
|---|---|---|
| Unit code | Unique, stable, nested in the administrative codes | Linking the selection, the listing and the field list |
| Domain | The unit’s domain of estimation | Strata, allocation |
| Residence | Urban or rural, if strata split by it | Strata |
| Sort keys | Administrative units below the domain, in nesting order | Implicit stratification, merging neighbors |
| Measure of size | Households, as recent as possible | PPS selection, certainty check |
The inputs have one row per domain of the last round, read from its report.
| Column | Content | Report table, DHS |
|---|---|---|
| Level | The estimate of each sizing indicator | Appendix B |
| Design effect | DEFT or deff, and the cases it rests on | Appendix B |
| Selected and completed | Households selected, share completed | Table A.5 |
| Eligible persons | Eligible persons found, and their response rate | Table A.5 |
| Clusters | Clusters allocated per stratum | Table A.3 |
| Frame households | Households per stratum in the old frame | Table A.1 |
The last two give the weighting loss of the last allocation, which must be divided out of a national or residence design effect before it is reused (Chapter 7). A MICS report gives the same information in Tables SR.1.1, SD.1, SD.2 and SE; a labor force survey, in its methodology and annual report annexes.
29.2 A frame the book has not planned on
The Rwanda frame of Chapter 27 serves here as a stand-in for a new country’s frame. Renamed to the generic columns, it goes through the steps of Chapter 5 and Chapter 11 unchanged.
The first table shows the frame in the generic columns, one row per EA. Every unit has a unique code and a positive count, and 105 units hold fewer than a take of 25. The last check finds 30 sector names that occur in more than one district, and the table lists those found in the most districts. The Gambian ward Kerewan likewise occurred in two districts. A sort within each domain handles such names, since it never compares two domains. A table that joins on the sector name alone would merge different sectors, so a key used for joins carries its domain.
The register of PSUs and a first-stage design follow with the same code as for The Gambia. Here each domain receives 20 clusters, split by residence in proportion to households.
psus <- my_frame |>
arrange(domain, residence, key_1, key_2, key_3, unit) |>
mutate(psu = merge_psus(unit, min_size = 25, size = households),
.by = c(domain, residence)) |>
summarise(key_1 = first(key_1), key_2 = first(key_2),
households = sum(households), .by = c(domain, residence, psu))
allocation <- psus |>
summarise(N = sum(households), .by = c(domain, residence)) |>
mutate(n = pmax(2, round(20 * N / sum(N))), .by = domain) |>
select(domain, residence, n)
head(psus)
#> domain residence psu key_1 key_2 households
#> 1 Bugesera Rural 5701010301 Gashora Biryogo 111
#> 2 Bugesera Rural 5701010001 Gashora Biryogo 93
#> 3 Bugesera Rural 5701010401 Gashora Biryogo 72
#> 4 Bugesera Rural 5701010501 Gashora Biryogo 216
#> 5 Bugesera Rural 5701010701 Gashora Biryogo 179
#> 6 Bugesera Rural 5701020101 Gashora Kabuye 134
head(allocation)
#> domain residence n
#> 1 Bugesera Rural 12
#> 2 Bugesera Urban 8
#> 3 Burera Rural 18
#> 4 Burera Urban 2
#> 5 Gakenke Rural 19
#> 6 Gakenke Urban 2
my_design <- sampling_design("A survey of my own") |>
stratify_by(domain, residence) |>
cluster_by(psu) |>
draw(n = allocation, method = "pps_systematic", mos = households,
control = c(key_1, key_2))
validate_frame(my_design, psus)
frame_summary(my_design, psus, detail = "unit") |>
summarise(largest = max(chance))
#> # A tibble: 1 × 1
#> largest
#> <dbl>
#> 1 0.312The register has one row per PSU, with the sort keys of its first EA, and the allocation one row per stratum, the form draw() reads. The largest chance of selection is well below 1, so no PSU is taken with certainty. From here, the allocation of Chapter 10, run on the inputs table of the new country, replaces the flat 20 clusters.
29.3 A synthetic population for the virtual survey
A virtual survey needs a population on the frame whose clustering matches what the last round measured. The Gambian one was built in three steps with decoupage, and the scripts are in sim/gambia/ of the book’s repository. The same steps apply to any frame with polygons.
First, households are placed in each unit, as many as its count. This is the slow step, a few minutes for a small country, and its result is kept.
library(decoupage)
placed <- populate_frame(units_with_polygons, households = "households",
id = "unit", district = "key_1",
region = "domain", urban = "urban",
place = "clustered", seed = 1)Second, an outcome is drawn for every person from a latent model with a domain effect, an EA effect, a household effect and a person effect (Chapter 6). The domain effects are solved so that each domain’s level matches the last round. The variance shares are the free parameters.
population <- sim_outcome(placed, "y", family = "binary",
prevalence = 0.5,
components = c(ea = 0.035, household = 0.10,
person = 0.865),
effects = c(domain_effects,
ea_extra = sqrt(0.15)),
seed = 2)Third, the parameters are calibrated. The last round’s design, declared as its report describes it, is drawn many times on the population with virtual_survey(), and each published DEFT is placed within the simulated spread. A grid of a few values for each variance share, run overnight, finds a setting where every published DEFT lies inside the central 90%. sim/gambia/calibrate.R does this for The Gambia.
Two lessons from The Gambia apply elsewhere. A residence rule may be too crude, and a measure of density, or another characteristic of the units, may describe homogeneity better (Chapter 6). And the national sampling error of the last round may not be reproducible on a new frame, because the frame itself has changed. That gap is a finding about the frame, not a failure of the population.
29.4 Beyond household surveys
The book follows household surveys, but its decisions are not tied to them.
An enterprise survey selects from a business register, a list frame rather than an area frame. Its measure of size is employment or turnover, its largest units are taken with certainty, often as a stratum of their own, and its strata cut the register by activity and size class. Coordinating its samples across surveys and years, so that a firm is not asked every time, uses permanent random numbers (Chapter 21). The decisions on targets, allocation and weights are the same, and so is the virtual survey, with a synthetic register in place of a synthetic population.
An agricultural survey often combines an area frame (segments of land) with a list of large holdings, and estimates with both (Chapter 23). It may screen a first sample to find holdings that grow a given crop and subsample them, a two-phase design (Chapter 22).
29.5 A checklist
Before a design goes to the field, each decision should have a record and a test.
| Decision | Record | Test |
|---|---|---|
| Domains and strata | Domains, strata, frame and its date | Frame checks, frame against an independent total |
| Inputs | Report, tables and pages of every value | Transcription sums, SE recomputed from R, N and DEFT |
| Targets and size | Indicator, measure, target, floors | Backtest of the formula on the last round |
| Design effect and take | Model and its parameters | Backtest against published design effects |
| Allocation | Rule or optimization, constraints | Backtest against the last allocation |
| PSUs | Merging rule, sort, method, seed | Certainty check, weights against the formula |
| Households | Listing, take, subsamples, replacement | Weights against the formula |
| Weights and errors | Formula, adjustments, variance method | Formula written out against survey |
| The whole design | Design file, report | Virtual survey, stress tests |
Appendix B expands each row.
29.6 Exercises
- Run the frame checks on
gmb24_easrenamed to the generic columns. Which check finds the ward that spans two districts? - Make the sort keys of the Rwanda stand-in unique across the country, and check that no key then spans two domains.
- Write the inputs table of your own country’s last DHS or MICS from its report, with the table and page of each value.
- The check that counts domains per key finds nothing at the district level. The ward check of Chapter 5, which counts districts per ward, finds Kerewan.
mutate(key_1 = paste(domain, key_1)), and likewise for the lower keys. The check of domains per key then returns no rows.- There is no single answer. Two checks catch most transcription errors: that the counts add up to the totals printed and that each SE equals DEFT times the SRS standard error of R and N.