Inclusion Probabilities: Stratified Random Sampling

strata_rs_probabilities(strata_var, prob = NULL, n = NULL,
  strata_n = NULL, strata_prob = NULL, check_inputs = TRUE)

Arguments

strata_var

A vector of length N that indicates which stratum each unit belongs to. Can be a character, factor, or numeric vector. (required)

prob

Use for a design in which either floor(N_stratum*prob) or ceiling(N_stratum*prob) units are sampled within each stratum. The probability of being sampled is exactly prob because with probability 1-prob, floor(N_stratum*prob) units will be sampled and with probability prob, ceiling(N_stratum*prob) units will be sampled. prob must be a real number between 0 and 1 inclusive. (optional)

n

Use for a design in which the scalar n describes the fixed number of units to sample in each stratum. This number does not vary across strata.

strata_n

Use for a design in which the numeric vector strata_n describes the number of units to sample within each stratum.

strata_prob

Use for a design in which strata_prob describes the probability of being sampled within each stratum. Differs from prob in that the probability of being sampled can vary across strata.

check_inputs

logical. Defaults to TRUE.

Value

A vector length N indicating the probability of being sampled.

Examples

strata_var <- rep(c("A", "B","C"), times = c(50, 100, 200)) probs <- strata_rs_probabilities(strata_var = strata_var) table(strata_var, probs)
#> probs #> strata_var 0.5 #> A 50 #> B 100 #> C 200
probs <- strata_rs_probabilities(strata_var = strata_var, prob = .2) table(strata_var, probs)
#> probs #> strata_var 0.2 #> A 50 #> B 100 #> C 200
probs <- strata_rs_probabilities(strata_var = strata_var, strata_prob = c(.1, .2, .3)) table(strata_var, probs)
#> probs #> strata_var 0.1 0.2 0.3 #> A 50 0 0 #> B 0 100 0 #> C 0 0 200
probs <- strata_rs_probabilities(strata_var = strata_var, strata_n = c(10, 40, 70)) table(strata_var, probs)
#> probs #> strata_var 0.2 0.35 0.4 #> A 50 0 0 #> B 0 0 100 #> C 0 200 0