Frames, strata and cost-aware allocation

Agricultural and establishment surveys often combine a list frame (known farms, cheap to reach by phone or on a planned visit) and an area frame (segments of territory, expensive to reach, complete in coverage). Even within one frame, strata differ in the cost of a unit. frame_allocation() is Cochran’s (1977, Section 5.5) allocation with a cost per unit in each stratum, in its two forms.

library(fieldopt)
library(dplyr, warn.conflicts = FALSE)
strata <- tibble(
  stratum = c("list: large", "list: small", "area"),
  size = c(300, 2500, 900),
  sd = c(80, 12, 35),
  cost = c(60, 35, 190)
)
strata
#> # A tibble: 3 × 4
#>   stratum      size    sd  cost
#>   <chr>       <dbl> <dbl> <dbl>
#> 1 list: large   300    80    60
#> 2 list: small  2500    12    35
#> 3 area          900    35   190

Minimum cost for a target variance

Fix the precision wanted for the estimated total and find the cheapest allocation that reaches it. The optimum has n_h proportional to N_h S_h / sqrt(c_h), rounded up and kept between 2 and N_h.

a <- frame_allocation(strata, target_variance = 2.5e7)
a
#> 
#> ── Allocation ──────────────────────────────────────────────────────────────────
#> Minimum cost for target variance 2.5e+07: cost 22640, variance 24720000.
#> # A tibble: 3 × 5
#>   stratum      size    sd  cost     n
#>   <chr>       <dbl> <dbl> <dbl> <int>
#> 1 list: large   300    80    60    88
#> 2 list: small  2500    12    35   143
#> 3 area          900    35   190    65

Minimum variance for a budget

Fix the budget instead and find the allocation with the smallest variance within it. Rounding is repaired so that the cost never exceeds the budget.

b <- frame_allocation(strata, budget = 30000)
b
#> 
#> ── Allocation ──────────────────────────────────────────────────────────────────
#> Minimum variance for budget 30000: cost 29980, variance 17830000.
#> # A tibble: 3 × 5
#>   stratum      size    sd  cost     n
#>   <chr>       <dbl> <dbl> <dbl> <int>
#> 1 list: large   300    80    60   116
#> 2 list: small  2500    12    35   191
#> 3 area          900    35   190    86

Where the field cost comes in

The cost column above is a planning value per unit. For the area frame it should include the travel, and that is what the routing part of the package estimates: run cost_variance_frontier() on the area frame with a cost model, read the mean cost per unit at the sample size under consideration, and use it as the stratum cost. The allocation then reflects how expensive the segments really are to visit, and the loop can be iterated once or twice until the stratum costs and sample sizes agree.

f <- cost_variance_frontier(
  area_frame,
  depot = "depot", cost_model = model,
  n_grid = c(40, 60, 80, 100), y = "crop"
)
area_cost <- f |>
  slice_min(abs(n - a$n[3]), n = 1) |>
  pull(cost_per_unit)
strata |>
  mutate(cost = if_else(stratum == "area", area_cost, cost)) |>
  frame_allocation(target_variance = 2.5e7)

Overlap between the frames (farms present in both) is not modelled here; the allocation treats the frames as strata of a single design.

Several study variables

A survey rarely has one target: crop area and cattle, or production and the number of holdings, each with its own precision. multivariate_allocation() finds the cheapest allocation that meets every target at once (Bethel 1989); the multipliers say which targets bind, and glance() shows the variance attained for each.

multi <- tibble(
  stratum = c("list", "area-high", "area-low"),
  size = c(2000, 300, 500), cost = c(40, 200, 160),
  sd_crop = c(12, 35, 18), sd_cattle = c(30, 10, 25)
)
ma <- multivariate_allocation(
  multi,
  sd = c("sd_crop", "sd_cattle"),
  target_cv = c(0.04, 0.06), totals = c(120000, 90000)
)
ma
#> 
#> ── Multivariate allocation ─────────────────────────────────────────────────────
#> Minimum cost 11200 for 2 targets.
#> sd_crop: target 23040000, attained 22600000 (binding).
#> sd_cattle: target 29160000, attained 28670000 (binding).
#> # A tibble: 3 × 4
#>   stratum    size  cost     n
#>   <chr>     <dbl> <dbl> <int>
#> 1 list       2000    40   169
#> 2 area-high   300   200     7
#> 3 area-low    500   160    19
glance(ma)
#> # A tibble: 2 × 7
#>   variable    target  attained multiplier     n  cost bounded
#>   <chr>        <dbl>     <dbl>      <dbl> <int> <dbl> <lgl>  
#> 1 sd_crop   23040000 22603942.  0.0000616   195 11200 FALSE  
#> 2 sd_cattle 29160000 28668674.  0.000305    195 11200 FALSE

Precision is often asked for parts of the population as well as for the whole: each region and the country. With the domain of each stratum in a column and the stratum means (which give the domain totals), domain_cv adds a target for every variable in every domain.

regions <- tibble(
  stratum = c("n-high", "n-low", "s-high", "s-low"),
  region = c("north", "north", "south", "south"),
  size = c(200, 900, 400, 1500), cost = c(260, 170, 220, 140),
  sd_crop = c(40, 9, 30, 6), mean_crop = c(90, 12, 70, 10)
)
da <- multivariate_allocation(
  regions,
  sd = "sd_crop", mean = "mean_crop",
  target_cv = 0.03, domain = "region", domain_cv = 0.04
)
da
#> 
#> ── Multivariate allocation ─────────────────────────────────────────────────────
#> Minimum cost 56410 for 3 targets.
#> sd_crop: target 4640000, attained 4239000.
#> sd_crop[north]: target 1327000, attained 1320000 (binding).
#> sd_crop[south]: target 2958000, attained 2919000 (binding).
#> # A tibble: 4 × 4
#>   stratum  size  cost     n
#>   <chr>   <dbl> <dbl> <int>
#> 1 n-high    200   260    68
#> 2 n-low     900   170    85
#> 3 s-high    400   220    69
#> 4 s-low    1500   140    65
glance(da)
#> # A tibble: 3 × 9
#>   variable domain  target attained     cv multiplier     n  cost bounded
#>   <chr>    <chr>    <dbl>    <dbl>  <dbl>      <dbl> <int> <dbl> <lgl>  
#> 1 sd_crop  <NA>   4639716 4239269. 0.0287    0         287 56410 FALSE  
#> 2 sd_crop  north  1327104 1320159. 0.0399    0.0186    287 56410 FALSE  
#> 3 sd_crop  south  2958400 2919110. 0.0397    0.00712   287 56410 FALSE

Here the regional targets bind and the national one follows from them.

One budget, several variables

When the budget is what is given, the question changes: each variable has its own best allocation of that budget, and they disagree. compromise_allocation() finds an allocation in between and reports, for each variable, its relative loss: the variance under the compromise divided by the variance the variable would have had with the budget allocated for it alone.

ca <- compromise_allocation(
  multi,
  sd = c("sd_crop", "sd_cattle"), budget = 30000,
  totals = c(120000, 90000)
)
ca
#> 
#> ── Compromise allocation (minimax) ─────────────────────────────────────────────
#> n = 474 for a cost of 30000 (budget 30000); largest loss 16.3% above a
#> variable's own optimum.
#> sd_crop: variance 5677000, 1.159 times its optimum 4899000 (CV 1.99%).
#> sd_cattle: variance 10550000, 1.163 times its optimum 9071000 (CV 3.61%).
#> # A tibble: 3 × 4
#>   stratum    size  cost     n
#>   <chr>     <dbl> <dbl> <int>
#> 1 list       2000    40   393
#> 2 area-high   300   200    33
#> 3 area-low    500   160    48
tidy(ca)
#> # A tibble: 3 × 7
#>   stratum    size  cost     n cost_total n_alone_sd_crop n_alone_sd_cattle
#>   <chr>     <dbl> <dbl> <int>      <dbl>           <dbl>             <dbl>
#> 1 list       2000    40   393      15720           275.              491. 
#> 2 area-high   300   200    33       6600            53.8              11.0
#> 3 area-low    500   160    48       7680            51.5              51.1

The default criterion, "minimax", makes the largest loss as small as possible, so no variable is sacrificed; the columns n_alone_* of tidy() show what each variable would have asked for. "weighted" minimises the weighted sum of the losses instead, which favours the variables with the larger weights:

compromise_allocation(
  multi,
  sd = c("sd_crop", "sd_cattle"), budget = 30000,
  criterion = "weighted", weights = c(3, 1)
) |>
  glance()
#> # A tibble: 2 × 8
#>   variable   optimum  attained  loss weight     n  cost criterion
#>   <chr>        <dbl>     <dbl> <dbl>  <dbl> <int> <dbl> <chr>    
#> 1 sd_crop   4899116.  5036321.  1.03   0.75   423 30000 weighted 
#> 2 sd_cattle 9071360. 12188525.  1.34   0.25   423 30000 weighted

The costs per unit above are given. compromise_design() takes them from the routing instead: it routes samples of several allocations, fits the cost per unit of each stratum and the travel shared by the whole sample, and allocates with the marginal costs, so that the budget is spent at the routed cost.

References

Bethel, J. (1989). Sample allocation in multivariate surveys. Survey Methodology, 15, 47–57.

Chatterjee, S. (1967). A note on optimum allocation. Scandinavian Actuarial Journal, 1967, 40–44.

Cochran, W. G. (1977). Sampling Techniques, third edition. Wiley.