Skip to contents

There are several functions to simulate a complex (or even simple random) sampling procedure on the school population generated by make_population():

  • gen_data_bin_srs() performs a simple random sample on the entire population.

  • gen_data_bin_strat() performs a stratified sampling procedure with the school type as strata, and the students as the PSU.

  • gen_data_bin_clust() performs a two-stage cluster sampling procedure (ignoring the strata) with schools being the PSU, and further clustering of class.

  • gen_data_bin_strcl() performs a two-stage stratified cluster sampling procedure where students are nested within class within school (PSU) within type (strata).

Usage

gen_data_bin_srs(
  population = make_population(1, seed = NULL),
  npsu = 3000,
  n,
  seed = NULL
)

gen_data_bin_strat(
  population = make_population(1, seed = NULL),
  npsu = 1000,
  n,
  seed = NULL
)

gen_data_bin_clust(
  population = make_population(1, seed = NULL),
  npsu = 140,
  n,
  seed = NULL
)

gen_data_bin_strcl(
  population = make_population(1, seed = NULL),
  npsu = 50,
  n,
  seed = NULL
)

Arguments

population

(tibble) Population generated by make_population().

npsu

(integer > 0) For the stratified sampling, this is the number of students within each strata to sample. For the cluster sampling, this is the number of schools (clusters) to sample. For the stratified cluster sampling, this is also the number of schools (clusters) per school type (strata). For the SRS procedure, this is the exact sample size.

n

(optional,integer > 0) Sample size. If provided, then the npsu argument is ignored and adjusted accordingly to achieve a sample size of (approximately) n.

seed

(numeric) The random seed.

Value

A tibble() containing ordinal binary values (0/1) for the items, as well as the population stratum and clusters (type, school, class).

Examples

if (FALSE) { # \dontrun{
pop <- make_population(2)
gen_data_bin_srs(pop)
gen_data_bin_strat(pop)
gen_data_bin_clust(pop)
gen_data_bin_strcl(pop)
} # }