Accept or reject sampling units against population density of potential sampling units

accept_reject_psu(
  x,
  svy,
  psu = "psu",
  match = NULL,
  pop = "pop",
  verbose = TRUE,
  show_plot = TRUE,
  save_plot = FALSE
)

Arguments

x

A data.frame of all potential primary sampling units (PSUs) to sample from each uniquely identified and with corresponding populations.

svy

A data.frame of survey data drawn via probability proportional to population size (PPS) approach from all the potential PSUs in x.

psu

A single character value or vector of values corresponding to the variable name/s for the primary sampling unit in x and svy. Default is "psu".

match

A single character value corresponding to the variable name for the primary sampling unit in x that matches the primary sampling unit in svy. Default is NULL which indicates that primary sampling unit in x is the same as primary sampling unit in svy.

pop

A single character value corresponding to the variable name for the population figures in x. Default is "pop".

verbose

Logical. Should text of sample acceptance or rejection be printed/shown? Default to TRUE.

show_plot

Logical. Should plot of sample acceptance or rejection be shown? Default to TRUE.

save_plot

Logical. Should plot of sample acceptance or rejection be saved? Default to FALSE. If set to TRUE when show_plot is FALSE, no plot will be saved.

Value

A data.frame drawn from svy that contains the primary sampling units selected by the acceptance and rejection sampling.

Author

Mark Myatt and Ernest Guevarra

Examples

accept_reject_psu( x = village_list, svy = sample_data, psu = c("id", "psu"), match = "cluster", pop = "population", verbose = FALSE, show_plot = FALSE )
#> # A tibble: 400 × 11 #> surveydate psu sex birthdate age weight height oedema muac measure #> <date> <dbl> <int> <date> <int> <dbl> <dbl> <int> <int> <chr> #> 1 2020-12-19 1 2 NA 8 8.8 66.1 0 163 l #> 2 2020-12-19 1 1 2020-03-20 9 8.6 72.4 0 149 l #> 3 2020-12-19 1 2 2019-04-16 20 10.1 79.6 0 142 l #> 4 2020-12-19 1 2 2018-12-05 24 9 79.2 0 136 h #> 5 2020-12-19 1 1 2018-11-12 25 13.3 86.8 0 157 h #> 6 2020-12-19 1 2 NA 28 9.2 85.9 0 118 h #> 7 2020-12-19 1 1 2018-01-16 35 15.1 95.6 0 147 h #> 8 2020-12-19 1 2 2017-12-02 36 12.6 94.5 0 148 h #> 9 2020-12-19 1 1 2017-08-17 40 13.2 86.1 0 166 h #> 10 2020-12-19 1 1 2017-02-09 46 13.9 91.3 0 170 h #> # … with 390 more rows, and 1 more variable: clothes <chr>