gmb24_eas <- readRDS("data/gmb24_eas.rds")
ea_clusters <- gmb24_eas |>
arrange(lga, urban_rural, district, ward, ea_id) |>
mutate(cluster = merge_psus(ea_id, min_size = 25, size = households),
.by = c(lga, urban_rural))
clusters <- ea_clusters |>
summarise(district = first(district), ward = first(ward),
households = sum(households), eas = n(),
.by = c(lga, urban_rural, cluster))
count(clusters, eas, name = "clusters")
#> eas clusters
#> 1 1 4955
#> 2 2 45
#> 3 3 3
min(clusters$households)
#> [1] 2511 Selecting the PSUs
The plan of Part II says how many EAs each stratum receives, 307 in all. This chapter selects them. It takes the seventh and eighth decisions of Figure 1.1, turning the frame into a list of primary sampling units (PSUs) and drawing the PSUs from it. Three questions come up along the way: what to do with EAs too small for the take, what to do with EAs so large that they must be taken, and which selection method to use.
11.1 From frame to PSU register
A DHS takes 25 households in each selected EA. 63 EAs of the 2024 frame hold fewer. Taken whole, they would give fewer interviews than planned and households with a different weight from their neighbors. The usual remedy is to merge each small EA with a neighbor before selection, so that every PSU holds at least the take.
merge_psus() merges along the row order, joining an EA too small for the take to the next EAs until the group reaches it. The frame is sorted by district and ward within each stratum first, so that the EAs it joins are neighbors in the administrative sense, and usually on the ground. A merged cluster keeps the district and ward of its first EA.
The register has 5,003 clusters, of which 48 combine two or three EAs. Every cluster holds at least 25 households. gmb_clusters() in the book’s code builds the same register for the chapters that follow.
11.2 Selection with probability proportional to size
The DHS selects the clusters of each stratum with probability proportional to their households, and then a fixed number of households in each.
In stratum \(h\) with \(M_h\) households, a cluster \(i\) of \(M_{hi}\) households is selected with probability \(\pi_{hi} = n_h M_{hi} / M_h\) when \(n_h\) clusters are drawn. If \(m\) households are then taken from the \(M_{hi}\) of the cluster, a household’s probability is \[ \pi_{hij} = \frac{n_h M_{hi}}{M_h} \times \frac{m}{M_{hi}} = \frac{n_h \, m}{M_h}, \] the same for every household of the stratum. The design is self-weighting within the stratum.
The self-weighting holds only if the listing finds the \(M_{hi}\) households the frame promised. When it finds \(L_{hi}\), the second stage is \(m / L_{hi}\), and the weight varies with \(L_{hi} / M_{hi}\) (Chapter 12).
The design takes the allocation of Chapter 10 from gmb_allocation(), one row per stratum with the clusters to select in n. The urban part of Kuntaur receives the fewest, the urban part of Brikama and the rural part of Basse the most.
allocation <- gmb_allocation()
allocation
#> lga urban_rural n
#> 1 Banjul Urban 34
#> 2 Basse Rural 39
#> 3 Basse Urban 17
#> 4 Brikama Rural 17
#> 5 Brikama Urban 39
#> 6 Janjanbureh Rural 22
#> 7 Janjanbureh Urban 5
#> 8 Kanifing Urban 36
#> 9 Kerewan Rural 18
#> 10 Kerewan Urban 7
#> 11 Kuntaur Rural 32
#> 12 Kuntaur Urban 3
#> 13 Mansakonko Rural 29
#> 14 Mansakonko Urban 9
sum(allocation$n)
#> [1] 307
dhs_design <- sampling_design("A DHS for The Gambia") |>
add_stage("Clusters") |>
stratify_by(lga, urban_rural) |>
cluster_by(cluster) |>
draw(n = allocation, method = "pps_systematic", mos = households,
control = c(district, ward)) |>
add_stage("Households") |>
draw(n = 25, method = "systematic")
dhs_design
#> ── Sampling Design: A DHS for The Gambia ────────────────────────
#>
#> ℹ 2 stages
#>
#> ── Stage 1: Clusters ────────────────────────────────────────────
#> • Strata: lga, urban_rural
#> • Cluster: cluster
#> • Draw: n = <custom data frame, per stratum>, method = pps_systematic, mos = households, control = c(district, ward)
#>
#> ── Stage 2: Households ──────────────────────────────────────────
#> • Draw: n = 25 (per cluster), method = systematic11.3 Certainty clusters
A cluster’s probability \(n_h M_{hi} / M_h\) exceeds one when it holds more than \(M_h / n_h\) households, the stratum’s households per selected cluster. Such a cluster must be selected with certainty and the rest of the stratum’s sample drawn from the other clusters. The check takes one call before selection. frame_summary() gives the probability every cluster would have.
units <- frame_summary(dhs_design, clusters, stages = 1, detail = "unit")
pools <- frame_summary(dhs_design, clusters, stages = 1, detail = "pool")
units |>
summarise(largest = max(chance), .by = pool_id) |>
left_join(select(pools, pool_id, pool_key, N, n_target), by = "pool_id") |>
select(pool_key, clusters = N, selected = n_target, largest) |>
arrange(desc(largest)) |>
head(3)
#> # A tibble: 3 × 4
#> pool_key clusters selected largest
#> <chr> <dbl> <dbl> <dbl>
#> 1 Banjul/Urban 93 34 0.592
#> 2 Mansakonko/Rural 167 29 0.381
#> 3 Mansakonko/Urban 39 9 0.3No cluster reaches certainty. Banjul comes closest. It selects 34 of its 93 clusters, and its largest has a probability of 0.59. Had Banjul kept 60 clusters, one would cross the line, and samplyr would take it with certainty and say so.
banjul_60 <- sampling_design() |>
cluster_by(cluster) |>
draw(n = 60, method = "pps_systematic", mos = households)
selected_60 <- execute(banjul_60, filter(clusters, lga == "Banjul"), seed = 1)
#> Stage 1: 1 unit is selected with certainty.
#> ℹ A unit whose share of its pool's size is above 1 / n has
#> chance 1, and the rest of the take is spread over the other
#> units.
#> ℹ Set `certainty_size` or `certainty_prop` in `draw()` to state
#> the rule in the design, or check before drawing with
#> `frame_summary()`.
table(selected_60$.certainty_1)
#>
#> FALSE TRUE
#> 59 1A certainty cluster is a stratum of its own for variance estimation. Its selection contributes no variance at the first stage. certainty_size and certainty_prop in draw() state the rule in the design instead of leaving it to the threshold of one.
11.4 Implicit stratification
Systematic PPS lays the clusters of a stratum end to end, each with a length equal to its households, and takes the clusters found at \(n_h\) evenly spaced points from a random start. control = c(district, ward) sorts the clusters by district and ward first. The evenly spaced points then fall in each district in proportion to its households, as if the districts were strata, without making them strata. This is the implicit stratification of DHS designs.
The effect shows over repeated draws. Each design is drawn 500 times, and the number of clusters selected in each district is compared with its expected number.
spread_of <- function(method, sorted) {
design <- sampling_design() |>
stratify_by(lga, urban_rural) |>
cluster_by(cluster)
design <- if (sorted) {
draw(design, n = allocation, method = method, mos = households,
control = c(district, ward))
} else {
draw(design, n = allocation, method = method, mos = households)
}
expected <- clusters |>
left_join(allocation, by = c("lga", "urban_rural")) |>
mutate(pi = n * households / sum(households),
.by = c(lga, urban_rural)) |>
summarise(expected = sum(pi), .by = district)
execute(design, clusters, seed = 3, reps = 500) |>
as.data.frame() |>
count(.replicate, district) |>
tidyr::complete(.replicate, district = expected$district,
fill = list(n = 0)) |>
left_join(expected, by = "district") |>
summarise(rms = sqrt(mean((n - expected)^2)))
}
spread <- c(systematic_sorted = spread_of("pps_systematic", TRUE)$rms,
brewer = spread_of("pps_brewer", FALSE)$rms)
spread
#> systematic_sorted brewer
#> 0.491831 1.942560On average, a district’s count misses its expected number by 0.49 clusters under the sorted systematic draw, and by 1.94 under Brewer’s method, which ignores the order. A survey that will also publish figures by district, or simply wants its clusters spread over the country, gains from the sort.
11.5 Choosing a PPS method
The DHS uses systematic PPS, and most NSOs do. It is simple, it can be done by hand, and it gives implicit stratification. It has a cost that the earlier chapters met twice. Because the points are evenly spaced, some pairs of clusters can never be selected together. Their joint inclusion probabilities, which an unbiased variance estimator needs, are then zero. DHS sampling errors treat the clusters as drawn with replacement instead, and that formula is only an approximation of the variance of a systematic draw.
Other PPS methods without replacement keep the sample size fixed and give every pair a positive joint probability. The sondage package, on which samplyr is built, implements the main ones.
| Method | method = |
Fixed size | Joint probabilities | Uses the sort order |
|---|---|---|---|---|
| Systematic PPS | "pps_systematic" |
Yes | Exact, can be zero | Yes |
| Brewer | "pps_brewer" |
Yes | Approximate | No |
| Sampford | "pps_sampford" |
Yes | Exact | No |
| Conditional Poisson | "pps_cps" |
Yes | Exact | No |
| Chromy | "pps_chromy" |
Yes, minimum replacement | Simulated | Yes |
| Systematic PPS, minimum replacement | "pps_systematic_mr" |
Yes, minimum replacement | Exact, can be zero | Yes |
| Multinomial | "pps_multinomial" |
Yes, with replacement | Exact | No |
Chromy’s method keeps the sort order like systematic PPS and gives most pairs a positive probability. Brewer’s and Sampford’s methods give up the sort for a design whose variance formula holds.
Under minimum replacement, a cluster larger than the sampling interval is not taken with certainty. It is hit once or twice, or more for a very large cluster, as its size dictates, and each hit is a row of its own with its own households. Systematic PPS with minimum replacement is the plain systematic draw on the cumulated sizes, with no cluster set aside first. A certainty_size or certainty_prop rule sets such clusters aside instead: each is taken once, and the other hits are drawn over the remaining clusters, as SAS does with CERTSIZE= for its systematic method. When samplyr exports a sample to survey, it treats both minimum-replacement methods as drawn with replacement, as DHS sampling errors treat their clusters. For the systematic one it warns that this is an approximation, since the frame order determines whether the standard error comes out too large or too small.
11.6 Virtual survey
Chapters 6 and 8 found that the standard error the survey reports could be too large in one LGA and too small in another. The virtual survey draws the plan with the systematic method and with Brewer’s, 1,000 times each, and compares the reported standard error with the true one.
gmb_synthetic <- readRDS("data/gmb_synthetic.rds")
inputs <- gmb_inputs()
response <- mutate(inputs, lga, household = completed, person = women_rr,
.keep = "none")
brewer_design <- sampling_design("Brewer") |>
add_stage("Clusters") |>
stratify_by(lga, urban_rural) |>
cluster_by(cluster) |>
draw(n = allocation, method = "pps_brewer", mos = households) |>
add_stage("Households") |>
draw(n = 25, method = "systematic")
systematic <- virtual_survey(dhs_design, gmb_synthetic, response, reps = 1000,
seed = 9)
brewer <- virtual_survey(brewer_design, gmb_synthetic, response, reps = 1000,
seed = 9)
share_selected <- clusters |>
count(lga, urban_rural, name = "N") |>
left_join(allocation, by = c("lga", "urban_rural")) |>
summarise(share_selected = sum(n) / sum(N), .by = lga)
tibble(lga = systematic$lga,
rse_sys = systematic$true_rse,
rse_brewer = brewer$true_rse,
ratio_sys = systematic$se_ratio,
ratio_brewer = brewer$se_ratio) |>
left_join(rename(share_selected, share = share_selected), by = "lga") |>
mutate(across(where(is.numeric), \(x) round(x, 3))) |>
as.data.frame()
#> lga rse_sys rse_brewer ratio_sys ratio_brewer share
#> 1 Banjul 0.100 0.095 1.057 1.115 0.366
#> 2 Kanifing 0.099 0.101 1.009 0.993 0.041
#> 3 Brikama 0.064 0.065 1.032 1.008 0.025
#> 4 Mansakonko 0.107 0.101 1.028 1.086 0.184
#> 5 Kerewan 0.115 0.109 0.929 0.999 0.048
#> 6 Kuntaur 0.101 0.104 1.107 1.082 0.143
#> 7 Janjanbureh 0.094 0.106 1.130 0.997 0.085
#> 8 Basse 0.103 0.096 0.974 1.030 0.114
#> 9 National 0.040 0.041 1.032 1.014 NAThe columns rse_ give the true RSE of the systematic and Brewer draws, the columns ratio_ the reported standard error over the true one, and share the share of the LGA’s clusters the plan selects. The two methods give the same national precision, and LGA precisions within about a point of each other. The difference is in the reported standard errors. Under the systematic draw, the ratio of the reported to the true standard error runs from 0.93 to 1.13 across the LGAs. Under Brewer’s method it runs from 0.99 to 1.12. Its largest ratios are in Banjul, Mansakonko and Kuntaur, the LGAs that select the largest shares of their clusters. There the omitted finite population correction makes the reported standard error too large, a conservative error.
The systematic draw adds a second effect, the order of the list. Its true variance depends on how the clusters happen to follow each other once sorted, and the with-replacement formula cannot see the order. In some LGAs the sort lines up similar clusters and the draw does better than the formula says; in others it does worse. Nationally the effects average out, and the reported RSE matches the true one.
For the Gambia, the plan keeps systematic PPS. Its LGA standard errors are off by at most 13%, it spreads the sample over districts, and it is the method GBoS and ICF know. A survey whose domain standard errors must be accurate, such as an evaluation that compares two districts, has reason to prefer Brewer’s or Sampford’s method.
11.7 Where the sample falls
selected <- execute(dhs_design, clusters, stages = 1, seed = 2025)
selected |>
as.data.frame() |>
count(lga, urban_rural, name = "selected") |>
left_join(allocation, by = c("lga", "urban_rural")) |>
filter(selected != n)
#> [1] lga urban_rural selected n
#> <0 rows> (or 0-length row.names)Every stratum has its planned number of clusters.
selected |>
as.data.frame() |>
mutate(ea_id = cluster) |>
map_eas(country = "gmb", outline = "districts", top = "lgas",
polygons = "gmb24_ea_polygons", size = 0.9)
At this scale an EA is too small to draw. A zoom on Banjul draws every EA and fills those of the selected clusters.
selected_eas <- ea_clusters$ea_id[ea_clusters$cluster %in% selected$cluster]
banjul <- ea_clusters$ea_id[ea_clusters$lga == "Banjul"]
map_zoom(banjul, selected_eas, country = "gmb",
polygons = "gmb24_ea_polygons")
Banjul’s sample takes 34 of its 93 EAs, more than one in three.
11.8 Backtest
Appendix A of the 2019-20 report gives the first-stage probability of a cluster as \(P_{1hi} = a_h M_{hi} / \sum_i M_{hi}\), with \(a_h\) the clusters selected in stratum \(h\) (Gambia Bureau of Statistics and ICF 2021). The weight samplyr computes for each selected cluster should be the inverse of that probability.
stratum_households <- clusters |>
summarise(M_h = sum(households), .by = c(lga, urban_rural))
selected |>
as.data.frame() |>
left_join(stratum_households, by = c("lga", "urban_rural")) |>
left_join(rename(allocation, a_h = n), by = c("lga", "urban_rural")) |>
mutate(p1 = a_h * households / M_h) |>
summarise(largest_difference = max(abs(.weight_1 - 1 / p1)))
#> largest_difference
#> 1 7.105427e-14The weights match the report’s formula to rounding. The report also says that the frame was sorted by district and ward within each stratum, which is control = c(district, ward), and that no household could replace a selected one, which Chapter 12 takes up.
11.9 How the other surveys select their PSUs
The Zimbabwe MICS of Chapter 26 draws its clusters the same way, and then meets EAs too large to list, which it cuts into segments (Chapter 12). The Malawi IHS of Chapter 28 sorts each district by residence, traditional authority and a curve through the EAs of each, so that consecutive EAs are close on the ground, and spreads its selected EAs over twelve months. The Rwanda LFS of Chapter 27 selects a master sample of PSUs once and rotates households within it (Chapter 20). Dzaleka refugee camp, sampled from a frame of shelters, uses a spatially balanced method (Chapter 23).
11.10 What to record
EAs with fewer than 25 households were merged with the next EA of their stratum in district and ward order, giving 5,003 clusters of at least 25 households. In each of the 14 strata, clusters were selected by systematic sampling with probability proportional to the number of households, after sorting by district and ward. No cluster had a probability of one. The first-stage probability of cluster \(i\) in stratum \(h\) is \(a_h M_{hi} / M_h\). The selection used seed 2025.
11.11 Exercises
- Without merging, how many of the selected clusters would hold fewer than 25 households? Draw the design on
gmb24_easwithcluster_by(ea_id)to find out. - Compute the largest number of clusters Banjul could select before a cluster reaches certainty.
- Replace
control = c(district, ward)bycontrol = householdsin the design. What does the sort do to the district spread, and why might a planner sort by size? - Draw the plan once with
"pps_sampford"and compare the weights of the selected clusters with those of the systematic draw.
- Execute a design with
cluster_by(ea_id)ongmb24_easand count the selected EAs withhouseholds < 25. Their probabilities add up to about 1.3, so a draw selects one or two small EAs on average. Each would give fewer than 25 interviews. - Certainty starts when the largest cluster’s households exceed \(M_h / n_h\). With Banjul’s largest cluster, that gives \(n_h < M_h / M_{\max}\), about 57 clusters.
- Sorting by size spreads the sample over small and large clusters rather than over districts. Its district spread is close to that of an unsorted draw. A planner sorts by size when size relates to the outcome more than geography does.
- The weights are the same for a given cluster, \(M_h / (a_h M_{hi})\), since every method keeps the same inclusion probabilities. Only the clusters selected differ.