R/min_int_allocation.R
min_int_allocation.RdFinds the smallest integer sample size \(n = \sum_h n_h\), with \(\min(m, N_h) \le n_h \le N_h\) (\(m\) = `minnumstrat`), such that the expected CV of the estimated mean (total) of every target variable does not exceed its target. Single- and multi-domain stratifications are supported.
min_int_allocation(
strata,
errors,
minnumstrat = 2,
divisor = c("N_h-1", "N_h"),
compare_ceiling = TRUE
)Data frame with one row per stratum and columns `N`, `M1`..`Mk`, `S1`..`Sk` (and `DOM1` for several domains), as returned by [SamplingStrata::buildStrataDF()] or by the `aggr_strata` element of [SamplingStrata::optimStrata()]. Column names are not case sensitive.
Data frame with columns `CV1`..`CVk` (and `domainvalue` for several domains), or a numeric vector of `k` target CVs (single domain).
Minimum number of units per stratum (default 2).
`"N_h-1"`: the `S_jh` are rescaled by \(\sqrt{N_h/(N_h-1)}\), i.e. variances have divisor \(N_h - 1\) as in the common evaluation of the paper; `"N_h"`: the `S_jh` are used as given (SamplingStrata convention).
Logical. If `TRUE` and SamplingStrata is available, the Bethel allocation rounded up is computed too and returned if smaller.
A list. For a single domain:
integer allocation by stratum
total sample size
achieved CVs of the target variables
Bethel allocation rounded up (`NA` if not computed)
continuous Bethel sample size (`NA` if not computed)
`"greedy"` or `"ceiling"`
For several domains:
allocation, aligned with the rows of `strata`
total sample size
named list of single-domain results
sample size by domain
matrix (domains x targets) of achieved CVs
totals over domains (`NA` if not computed)
method chosen in each domain
For each target variable \(j\) the constraint is $$V_j(n) = \sum_h W_h^2 \left(\frac{1}{n_h} - \frac{1}{N_h}\right) S_{jh}^2 \le (CV_j \bar{Y}_j)^2,$$ with \(W_h = N_h / N\) and \(\bar{Y}_j = \sum_h W_h M_{jh}\) (Equation 1 of the paper).
The algorithm is a marginal allocation:
start from the lower bounds \(n_h = \min(m, N_h)\);
while some constraint is violated, add one unit to the stratum with the largest reduction of the violated variances, each normalised by its target: \(\sum_{j\ violated} W_h^2 S_{jh}^2 (1/n_h - 1/(n_h+1)) / V_j^*\);
(several targets) remove, one at a time, any unit whose removal keeps all the constraints satisfied.
With a single target the result is the optimal integer allocation (marginal gains decrease with \(n_h\), so the greedy allocation is optimal for every total). With several targets the result is a heuristic: it always satisfies the constraints and, if `compare_ceiling = TRUE`, is never larger than the Bethel allocation rounded up stratum by stratum.
**Domains.** If `strata` has a column `DOM1` (case insensitive) and `errors` is a data frame with a column `domainvalue`, the allocation is computed separately in every domain with its own CV targets (the optimisation is independent across domains, as in Bethel's algorithm). Otherwise a single domain is assumed and only the first row of `errors` is used.
[SamplingStrata::optimStrata()], [SamplingStrata::bethel()]
if (FALSE) { # \dontrun{
# Evaluate solution
outstrata <- solution$aggr_strata
expected_CV(outstrata)
# Minimal integer solution
newalloc <- min_int_allocation(strata = outstrata, errors = errors, minnumstrat = 2,
divisor = "N_h", compare_ceiling = TRUE)
# Verify again
outstrata$SOLUZ <- newalloc$n_h
expected_CV(outstrata)
} # }