21  Coordinating samples with permanent random numbers

A statistical office draws many samples from the same frames. Its business surveys use one register, and the same large firms are asked for their turnover, their employment, their investment and their prices, month after month. Its household surveys use one list of EAs, and a community visited by the DHS one year may receive the labor force survey the next. Coordination controls how much two samples from the same frame share. Positive coordination keeps the same units, which helps estimates of change. Negative coordination avoids them, which spreads the response burden.

Permanent random numbers (PRNs) do this with almost no machinery. This chapter shows how, on a register of enterprises and on the EAs of The Gambia, and finds that a rule commonly taught for one family of methods backfires on another.

21.1 Permanent random numbers

Each unit of the frame is given a single random number between 0 and 1, its PRN, kept with the unit from one draw to the next. A method that selects by the PRN gives the same sample when the PRN is reused, and a different one when it is moved.

NoteSelection by permanent random numbers

Under Bernoulli or Poisson sampling, unit \(i\) with PRN \(u_i\) and inclusion probability \(\pi_i\) is selected when \(u_i < \pi_i\). A second sample with the PRN \(u'_i = (u_i - \pi_i) \bmod 1\) and probability \(\pi'_i\) shares no unit with the first when \(\pi_i + \pi'_i \leq 1\) for every unit (Ohlsson 1995).

Order sampling takes the \(n\) units with the smallest ranks \(\xi_i = u_i / \pi_i\) (sequential Poisson) or a related transform (Pareto). The sample size is fixed, and the \(\pi_i\) are targets that hold approximately (Rosén 1997; Ohlsson 1998).

samplyr accepts a PRN with bernoulli, pps_poisson, pps_sps, pps_pareto and scps.

21.2 An enterprise register

ken_enterprises is a synthetic register of Kenyan enterprises. Each enterprise receives a PRN, stored in the register rather than drawn again in each script, since coordination survives only as long as the PRN does.

data(ken_enterprises)
set.seed(1)
register <- ken_enterprises |>
  mutate(prn = runif(n()))
register |>
  select(enterprise_id, sector, employees, revenue_millions, prn) |>
  head(4)
#> # A tibble: 4 × 5
#>   enterprise_id sector           employees revenue_millions   prn
#>   <chr>         <fct>                <int>            <dbl> <dbl>
#> 1 KEN_00001     Chemicals & Che…        43            108   0.266
#> 2 KEN_00002     Chemicals & Che…        15             45.7 0.372
#> 3 KEN_00003     Chemicals & Che…         6              4.4 0.573
#> 4 KEN_00004     Chemicals & Che…        17             40   0.908

fraction <- 200 / nrow(register)
bernoulli <- sampling_design() |>
  draw(frac = fraction, method = "bernoulli", prn = prn)

wave_1 <- execute(bernoulli, register, seed = 10)
same_prn <- execute(bernoulli, register, seed = 20)
shifted <- execute(bernoulli,
                   mutate(register, prn = (prn - fraction) %% 1), seed = 20)

c(wave_1 = nrow(wave_1),
  shared_same_prn = sum(same_prn$enterprise_id %in% wave_1$enterprise_id),
  shared_shifted = sum(shifted$enterprise_id %in% wave_1$enterprise_id))
#>          wave_1 shared_same_prn  shared_shifted 
#>             208             208               0

With the same PRN, the second draw is the first one, whatever its seed. With the PRN shifted by the fraction, it shares nothing. The PRN must be updated on the whole register, not only on the selected units, or the next draw no longer follows the design.

A business survey usually wants a fixed sample size and probabilities proportional to size, so that large enterprises are selected more often. Sequential Poisson sampling, pps_sps, gives both. Four waves, each with the PRN shifted by the target probabilities of the last, take mostly new enterprises, but not only new ones.

register <- register |>
  mutate(pik = inclusion_prob(revenue_millions, 200))
c(enterprises = nrow(register), certain = sum(register$pik == 1))
#> enterprises     certain 
#>       17004           5
sps <- sampling_design() |>
  draw(n = 200, method = "pps_sps", mos = revenue_millions, prn = prn)

waves <- list()
frame <- register
for (wave in 1:4) {
  waves[[wave]] <- suppressMessages(execute(sps, frame, seed = 1))
  frame <- mutate(frame, prn = (prn - pik) %% 1)
}
ids <- lapply(waves, `[[`, "enterprise_id")
outer(ids, ids, Vectorize(\(x, y) length(intersect(x, y))))
#>      [,1] [,2] [,3] [,4]
#> [1,]  200   15   41   40
#> [2,]   15  200   12   31
#> [3,]   41   12  200   21
#> [4,]   40   31   21  200

The matrix counts the enterprises two waves share, wave against wave, with the sample size of 200 on the diagonal.

The largest enterprises have probabilities near or equal to one and are in every wave, as they must be. Between waves, the register’s births receive fresh PRNs, closures leave it, and the target probabilities are computed again before each draw.

21.3 Two household surveys on one frame

GBoS plans the DHS of Chapter 25 and, the same year, a labor force survey of about 200 clusters, allocated in proportion to households. Both select clusters with probability proportional to households from the frame of Chapter 11. Drawn independently, the two surveys would visit some of the same EAs and list them twice. With PRNs they can be kept apart.

Both are drawn here by sequential Poisson, with a PRN on the clusters. The labor force survey’s PRN is set by one of four rules, and each rule is tried with 200 fresh sets of PRNs.

clusters <- gmb_clusters()
dhs_allocation <- gmb_allocation()
lfs_allocation <- clusters |>
  summarise(N = sum(households), .by = c(lga, urban_rural)) |>
  mutate(n = pmax(2, round(200 * N / sum(N)))) |>
  select(lga, urban_rural, n)

left_join(rename(dhs_allocation, dhs = n),
          rename(lfs_allocation, lfs = n), by = c("lga", "urban_rural"))
#>            lga urban_rural dhs lfs
#> 1       Banjul       Urban  34   4
#> 2        Basse       Rural  39  10
#> 3        Basse       Urban  17   6
#> 4      Brikama       Rural  17  25
#> 5      Brikama       Urban  39  71
#> 6  Janjanbureh       Rural  22   8
#> 7  Janjanbureh       Urban   5   2
#> 8     Kanifing       Urban  36  42
#> 9      Kerewan       Rural  18  12
#> 10     Kerewan       Urban   7   6
#> 11     Kuntaur       Rural  32   7
#> 12     Kuntaur       Urban   3   2
#> 13  Mansakonko       Rural  29   6
#> 14  Mansakonko       Urban   9   2

clusters <- clusters |>
  left_join(rename(dhs_allocation, n_dhs = n), by = c("lga", "urban_rural")) |>
  mutate(pik_dhs = inclusion_prob(households, first(n_dhs)),
         .by = c(lga, urban_rural))

dhs <- sampling_design() |>
  stratify_by(lga, urban_rural) |>
  cluster_by(cluster) |>
  draw(n = dhs_allocation, method = "pps_sps", mos = households, prn = prn)
lfs <- sampling_design() |>
  stratify_by(lga, urban_rural) |>
  cluster_by(cluster) |>
  draw(n = lfs_allocation, method = "pps_sps", mos = households,
       prn = prn_lfs)

rules <- c("independent", "shift by target", "reverse", "shift by cut-off")

set.seed(5)
runs <- lapply(1:200, function(r) {
  frame <- mutate(clusters, prn = runif(n()))
  dhs_sample <- suppressMessages(execute(dhs, frame, seed = 1))
  cut_off <- frame |>
    filter(cluster %in% dhs_sample$cluster) |>
    summarise(cut_off = max(prn / pik_dhs), .by = c(lga, urban_rural))
  frame <- left_join(frame, cut_off, by = c("lga", "urban_rural"))
  prn_lfs <- list(
    independent = runif(nrow(frame)),
    `shift by target` = (frame$prn - frame$pik_dhs) %% 1,
    reverse = 1 - frame$prn,
    `shift by cut-off` = (frame$prn - pmin(1, frame$cut_off * frame$pik_dhs) -
                            1e-9) %% 1
  )
  samples <- lapply(prn_lfs, \(u)
    suppressMessages(execute(lfs, mutate(frame, prn_lfs = u), seed = 1)))
  list(shared = sapply(samples, \(s) sum(s$cluster %in% dhs_sample$cluster)),
       samples = samples)
})

shared <- sapply(runs, `[[`, "shared")
tibble(rule = rules, mean_shared = rowMeans(shared),
       most_shared = apply(shared, 1, max))
#> # A tibble: 4 × 3
#>   rule             mean_shared most_shared
#>   <chr>                  <dbl>       <int>
#> 1 independent             12.5          22
#> 2 shift by target         20.6          45
#> 3 reverse                  0             0
#> 4 shift by cut-off         0             0

The table above gives the clusters each survey takes in each stratum, the DHS by its joint allocation and the labor force survey in proportion to households. The second table counts, for each rule, the clusters the two samples share, on average and at most over the 200 sets of PRNs. Independent PRNs share about 12 clusters. Shifting by the target probabilities, the rule that is exact for Bernoulli sampling, shares more, 21 on average. Sequential Poisson selects the units whose ratio \(u_i / \pi_i\) falls below a cut-off that can be slightly above 1. A DHS cluster selected with a ratio just above 1 gets, after the shift, a PRN just above 0, and is the first cluster the labor force survey takes. Reversing the PRN, or shifting by the cut-off each stratum actually used, puts every DHS cluster at the far end of the scale, and the two surveys share nothing.

21.4 Check

Under independent draws, the expected number of clusters in both samples is \(\sum_i \pi_i \pi'_i\), which the simulation should reproduce.

clusters |>
  left_join(rename(lfs_allocation, n_lfs = n), by = c("lga", "urban_rural")) |>
  mutate(pik_lfs = inclusion_prob(households, first(n_lfs)),
         .by = c(lga, urban_rural)) |>
  summarise(expected = sum(pik_dhs * pik_lfs))
#>   expected
#> 1 12.75313

The independent draws above shared 12 clusters on average, to set beside this expected count.

21.5 Virtual survey

Coordination changes which clusters a survey takes, not the probability of each. The labor force survey drawn with a reversed PRN is still a PPS sample, since \(1 - u_i\) is as uniform as \(u_i\). The virtual survey checks this. The 200 labor force samples above, with 25 households in each cluster, are fielded on the synthetic Gambia, and each gives an estimate of mCPR, the outcome that population carries.

lfs_design <- sampling_design() |>
  add_stage("Clusters") |>
    stratify_by(lga, urban_rural) |>
    cluster_by(cluster) |>
    draw(n = lfs_allocation, method = "pps_sps", mos = households) |>
  add_stage("Households") |>
    draw(n = 25, method = "systematic")

gmb_synthetic <- readRDS("data/gmb_synthetic.rds")
inputs <- gmb_inputs()
response <- mutate(inputs, lga, household = completed, person = women_rr,
                   .keep = "none")

field <- function(rule) {
  samples <- lapply(seq_along(runs), \(r)
    mutate(as.data.frame(runs[[r]]$samples[[rule]]), .replicate = r))
  virtual_survey(lfs_design, gmb_synthetic, response,
                 selections = bind_rows(samples), seed = 6)
}
coordinated <- lapply(c(independent = "independent", reverse = "reverse"),
                      field) |>
  bind_rows(.id = "rule") |>
  filter(lga == "National") |>
  mutate(rule, truth, mean, true_rse, .keep = "none")
coordinated |>
  mutate(across(where(is.numeric), \(x) round(x, 4)))
#> # A tibble: 2 × 4
#>   rule        truth  mean true_rse
#>   <chr>       <dbl> <dbl>    <dbl>
#> 1 independent 0.170 0.170   0.0385
#> 2 reverse     0.170 0.170   0.0419

The coordinated survey estimates mCPR without bias. Its true RSE differs from that of the independent survey by 9%. The Monte Carlo error of an RSE from 200 replicates is about 5% of its value, so the difference is less than twice that error.

21.6 Spreading the burden

Avoiding overlap between two surveys is one control. Another is to keep the number of burdened units in each sample steady. Spatially correlated Poisson sampling, scps, spreads a sample over its spread variables, usually coordinates. Matei et al. (2023) spread it over a measure of response burden, so that burdened units repel each other within a sample, and drew a second survey with \(1 - u_i\) (Grafström and Matei 2018). With prn, scps visits each pool in the frame’s row order or the control order, so both draws need the same order. scps has no linearization variance, and estimates use replicate weights.

21.7 How the other surveys coordinate

Business registers were the first home of PRNs, and several statistical offices run a coordination system over all their business surveys (Ohlsson 1995). Household surveys coordinate through a master sample more often than through PRNs. The Rwanda LFS of Chapter 27 selects its panels from one master sample and controls overlap by its rotation (Chapter 20). A PRN controls overlap between separate draws; a rotation controls how long a selected unit stays. A survey program can use both.

21.8 What to record

TipFor the sample design report

Each cluster of the frame carries a permanent random number, kept with the frame. The DHS clusters are selected by sequential Poisson sampling with probability proportional to households, and the labor force survey of the same year with the reversed number, \(1 - u_i\), so that the two surveys share no cluster. The permanent random numbers are stored with the frame and the design files of both surveys.

21.9 Exercises

  1. Under Bernoulli sampling with fractions of 0.6 and 0.6, how many units must the two samples share at least? Check with the register.
  2. Use pps_pareto instead of pps_sps for the two household surveys. Does the shift by the target probabilities still share more than independent draws?
  3. Give the labor force survey the same PRN as the DHS. How many clusters do the two surveys share, and when would GBoS want that?
  1. A unit is in both when \(u_i < 0.6\) and \((u_i - 0.6) \bmod 1 < 0.6\), which holds for \(u_i\) between 0.2 and 0.6, so about 20% of the register. The shift cannot separate samples whose fractions add up to more than 1.
  2. Yes, about 20 clusters on average against 12 for independent draws. Pareto sampling also selects by a ratio whose cut-off can exceed the target, and the units just above it return first after the shift.
  3. About 157 of the labor force survey’s 203 clusters are DHS clusters, since both take the clusters with the smallest PRN relative to their size. That is positive coordination. GBoS would want it to link the two surveys in the same communities, or to reuse the DHS listing.