knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Multivariate optimal allocation for different domains in one and two stages stratified sample design. R2BEAT extends the Neyman (1934) – Tschuprow (1923) allocation method to the case of several variables, adopting a generalization of the Bethel’s proposal (1989). R2BEAT develops this methodology but, moreover, it allows to determine the sample allocation in the multivariate and multi-domains case of estimates for two-stage stratified samples. It also allows to perform both Primary Stage Units and Secondary Stage Units selection.
R2BEAT easily manages all the complexity due to the optimal sample allocation in two-stage sampling design, and provides several outputs for evaluating the allocation. Its name stands for "R 'to' Bethel Extended Allocation for Two-stage". It is an extension of another open-source software called Mauss-R (Multivariate Allocation of Units in Sampling Surveys), implemented by ISTAT researchers (https://www.istat.it/en/methods-and-tools/methods-and-it-tools/design/design-tools/mauss-r). Mauss-R determines the optimal sample allocation in multivariate and multi-domains estimation, for one-stage stratified samples.
To complete the suite of tools developed by Istat in order to cover the stratified sample design, we cite SamplingStrata (https://CRAN.R-project.org/package=SamplingStrata), that allows to jointly optimize both the stratification of the sampling frame and the allocation, still in the multivariate multidomain case (only for one-stage designs), and MultiWay.Sample.Allocation, that allows to determine the optimal sample allocation for multi-way stratified sampling designs and incomplete stratified sampling designs (https://www.istat.it/en/methods-and-tools/methods-and-it-tools/design/design-tools/multiwaysampleallocation).
For a complete illustration of the methodology see the vignette "R2BEAT methodology and use" (https://barcaroli.github.io/R2BEAT/articles/R2BEAT_methodology.html).
A complete example is illustrated in the vignette "Two-stage sampling design workflow" (https://barcaroli.github.io/R2BEAT/articles/R2BEAT_workflow.html).
You can install the released version of R2BEAT from CRAN with:
``` {r, eval=FALSE, echo=TRUE} install.packages("R2BEAT")
or the last version of R2BEAT from github with: ``` {r, eval=FALSE, echo=TRUE} install.packages("devtools") devtools::install_github("barcaroli/R2BEAT")
``` {r, eval=FALSE, echo=TRUE} library(R2BEAT)
library(readr) pop <- read_rds("https://github.com/barcaroli/R2BEAT_workflows/blob/master/pop.RDS?raw=true") str(pop)
cv <- as.data.frame(list(DOM=c("DOM1","DOM2"), CV1=c(0.02,0.03), CV2=c(0.03,0.06), CV3=c(0.03,0.06), CV4=c(0.05,0.08))) cv
samp_frame <- pop
samp_frame$one <- 1
id_PSU <- "municipality"
id_SSU <- "id_ind"
strata_var <- "stratum"
target_vars <- c("income_hh","active","inactive","unemployed")
deff_var <- "stratum"
domain_var <- "region"
delta = 1 # households = survey units
minimum <- 50 # minimum number of SSUs to be interviewed in each selected PSU
deff_sugg <- 1.5 # suggestion for the deff value
inp <- prepareInputToAllocation1(samp_frame,
id_PSU,
id_SSU,
strata_var,
target_vars,
deff_var,
domain_var,
minimum,
delta,
deff_sugg)
alloc <- beat.2st(stratif = inp$strata, errors = cv, des_file = inp$des_file, psu_file = inp$psu_file, rho = inp$rho, deft_start = NULL, effst = inp$effst, minPSUstrat = 2, minnumstrat = 50)
sample_1st <- select_PSU(alloc, type="ALLOC", pps=TRUE, plot=TRUE) sample_1st$PSU_stats
sample_2st <- select_SSU(df=pop, PSU_code="municipality", SSU_code="id_ind", PSU_sampled=sample_1st$sample_PSU) head(sample_2st)
```
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.