---
title: 'R2BEAT: Optimal Two-Stage Survey Allocation'
url: https://www.emergentmind.com/topics/r2beat-package
type: topic
---

# R2BEAT: Optimal Two-Stage Survey Allocation

R2BEAT ("R 'to' Bethel Extended Allocation for Two-stage sampling") is an R package designed to address optimal allocation for complex survey sampling under stratification, multivariate objectives, multiple reporting domains, two-stage selection designs, and strict budgetary or logistical constraints. Its methodological foundation extends classical allocation models—specifically the Neyman allocation for single-variable, single-domain stratified sampling—through the Bethel (1989) multivariate framework and the two-stage iterative approach proposed by Falorsi et al. (1998), enabling its application to multi-purpose, multi-domain sample surveys common in both official and non-official statistics. R2BEAT operationalizes these frameworks in a complete environment, supporting the full process from input data preparation, through allocation optimization, sample selection (including Primary Sampling Units [PSUs] and Secondary Sampling Units [SSUs]), to results diagnostics and validation [2209.06532].

## 1. Purpose, Scope, and Distinguishing Features

R2BEAT is purpose-built to handle the allocation phase in survey design when the survey targets:
- Multiple target variables $y_1,\dots,y_J$ reflecting multipurpose objectives.
- Multiple estimation domains (e.g., by geography, demographic group) with domain-level precision constraints.
- Two-stage sample designs, in which the first stage selects PSUs and the second selects SSUs within sampled PSUs.
- Constraints on total budget, total number of SSUs, minimum SSUs per PSU, and minimum PSUs per stratum.

A key distinguishing feature is R2BEAT's extension of the one-stage Bethel allocation to accommodate two-stage (PSU→SSU) survey architectures using the Falorsi et al. iterative method. The package’s functionality covers the entire allocation-selection pipeline, including direct sample selection via Sampford’s method for PSUs and systematic or simple random sampling (SRS) for SSUs, as well as calculation and diagnostic reporting for inclusion probabilities and sampling weights.

## 2. Theoretical Foundations and Core Allocation Formulas

### 2.1 Tschprow–Neyman Optimal Allocation

For classical stratified sampling with $H$ strata and a single variable of interest, given stratum sizes $N_h$ and stratum standard deviations $S_h$, the minimum-variance allocation for a fixed total sample size $n$ is:

$$
n_h^{\rm OPT} = n \frac{N_h S_h}{\sum_{k=1}^H N_k S_k}
$$

This allocation minimizes the estimator variance. Extensions for variable stratum-specific unit costs $c_h$ and budget $C$ substitute cost-weighted terms and a budget constraint.

### 2.2 Bethel’s Multivariate and Multi-domain Allocation

For the multivariate, multi-domain case with $J$ variables $y_i$ and $D$ domains $d$, the goal is to meet planned relative precision (CV) constraints across all variables and domains:

$$
\widehat{CV}\left(\hat{\bar Y}_{i}^{(d)}\right) \le \delta_{i,d}
$$

with

$$
\widehat{CV}\left(\hat{\bar Y}_{i}^{(d)}\right) = \frac{\sqrt{\mathrm{Var}(\hat{\bar Y}_{i}^{(d)})}}{\hat{\bar Y}_{i}^{(d)}}
$$

The allocation is derived by iterative solution of the Lagrangian optimization:

$$
\min_{\{n_h\}} C = \sum_{h=1}^H c_h n_h,\qquad
\text{s.t.}\quad V_{i,d}(\{n_h\}) \le (\delta_{i,d} \mu_{i,d})^2 \;\forall i,d
$$

Bethel’s algorithm solves this problem with root-finding for the dual variables (Lagrange multipliers), iterating to find the optimal (possibly fractional) $n_h$ under all precision constraints, followed by rounding [2209.06532].

### 2.3 Falorsi et al.: Two-stage and Multi-domain Extension

In two-stage designs, with intraclass correlation $\rho_{i,h}$ and average SSUs per PSU ($b_h$), the design effect inflates the stratum variance:

$$
deff_{i,h} = 1 + \rho_{i,h}(b_h - 1)
$$

The allocation is computed via an algorithm that iteratively:
- Inflates standard deviations by $\sqrt{deff_{i,h}}$,
- Solves the multivariate Bethel allocation,
- Updates $b_h$ and $deff_{i,h}$,
- Converges when all changes are below a set tolerance.

Domains are incorporated by including a constraint for each (variable, domain) pair, under the restriction that domains do not cross stratum boundaries [2209.06532].

## 3. Principal Functions and Workflow in R2BEAT

R2BEAT functionality is structured across several critical phases. Main functions are summarized below:

| Phase               | Function / Description                                                | Required Inputs              |
|---------------------|----------------------------------------------------------------------|------------------------------|
| Data Preparation    | `prepareInputToAllocation1`, `prepareInputToAllocation2`,             | Sampling frame, strata, variables, domains, min SSU, CV targets          |
|                     | `sensitivity_min_SSU`, `check_input`                                 |                              |
| Allocation          | `beat.1st` (one-stage Bethel)                                        | Stratum data, error/CV targets  |
|                     | `beat.2st` (two-stage Falorsi-Bethel)                                | Stratum data, PSU/SSU frames, intraclass $\rho$, optional design/effect inputs|
| Sample Selection    | `select_PSU` (Sampford’s PPS for PSUs, sub-strata formation)         | Allocation result, PSU frame |
|                     | `select_SSU` (systematic/SRS for SSUs, $\pi_I, \pi_{II}$)            | Sampled PSUs, SSU frame      |
| Diagnostics         | `eval_2stage` (empirical Monte Carlo check for CV compliance)         | Sample frames, allocation, $nsampl$|

Each function returns objects with detailed information on design effects, allocations, inclusion probabilities, achieved CVs, and diagnostic outputs.

## 4. Exemplary Usage: Code Snippets for One- and Two-Stage Allocation

A typical one-stage workflow involves:
- Defining stratum sizes and standard deviations,
- Declaring target CVs for each (variable, domain) pair,
- Allocating samples via `beat.1st`,
- Inspecting allocation tables and sensitivity (planned vs actual CVs).

A two-stage workflow extends this by:
- Defining PSU and SSU frames, stratum/PSU relationships, measures of size,
- Estimating stratum-level $N_h$, variable-specific $S_{i,h}$, intraclass $\rho_{i,h}$,
- Running `beat.2st` for optimal allocation,
- Selecting PSUs via `select_PSU`, and SSUs via `select_SSU`,
- Performing empirical CV checks with `eval_2stage`.

These workflows are supported by explicit R code within the package documentation, illustrating each step from synthetic frame construction through allocation, selection, and validation of the resulting survey samples.

## 5. Outputs, Diagnostics, and Validation

R2BEAT provides a range of outputs supporting both allocation decision-making and post-hoc validation:
- For allocation, outputs include planned sample sizes, optimal/proportional/equal allocations, CV sensitivity, and (for two-stage) summary tables by iteration (PSU/SSU counts), expected CVs, and design effects ($deft_c$).
- For sample selection, explicit inclusion probabilities at each stage ($\pi_I$, $\pi_{II}$), as well as combined design weights ($d_k = 1/(\pi_I \pi_{II})$).
- Diagnostics include graphical representations for sub-strata formation, as well as `eval_2stage` which runs a Monte Carlo simulation (default 500 draws) to empirically assess compliance with CV constraints over multiple random sample realizations.

## 6. Application Example: Self-contained Two-Stage Allocation

A minimal, self-contained example illustrates R2BEAT’s workflow:
- Synthetic PSU/SSU frames are defined with two strata, each with variable cluster sizes and response variables ($y_1$, $y_2$).
- Stratum population sizes and standard deviations are computed and combined.
- CV requirements and clustering parameters ($\rho$) are set.
- The two-stage algorithm (`beat.2st`) computes allocations and design effects.
- Sub-strata are visualized during PSU selection (`select_PSU`).
- SSUs are sampled within selected PSUs, and final weights are calculated.
- A Monte Carlo routine (`eval_2stage`) confirms that realized CVs remain within planned bounds [2209.06532].

This workflow demonstrates the end-to-end capabilities of R2BEAT for complex stratified two-stage surveys, with reproducible code and interpretable output to facilitate rigorous design and analysis.

## 7. Context, Limitations, and Theoretical Underpinnings

R2BEAT is grounded in the classical survey sampling literature, implementing the Neyman (1934) allocation for single-variable settings, Bethel’s (1989) methodology for multivariate, multi-domain stratified sampling, and Falorsi et al.’s (1998) approach for extending these results to two-stage sample designs by iteratively accounting for design effects driven by intraclass correlation at the PSU level. Its design ensures that allocations are feasible under realistic domain and clustering structures (domains must nest within strata), that cost and precision constraints are respected, and that all calculation steps are transparent and reproducible.

A plausible implication is that, by automating allocation, selection, and diagnostics for complex survey designs, R2BEAT enables broader adoption of optimal allocation strategies in official statistics and large-scale multipurpose surveys, offering a standardized, reproducible technical platform for practitioners [2209.06532].

Source: https://www.emergentmind.com/topics/r2beat-package