You can either give obtain_inclusion_probabilities() an declaration, as created by
declare_rs or you can specify the other arguments to describe a random sampling procedure.
This function is especially useful when units have different inclusion probabilities and the analyst plans to use inverse-probability weights.
obtain_inclusion_probabilities(declaration = NULL, N = NULL, strata = strata_var, clusters = clust_var, n = NULL, prob = NULL, strata_n = NULL, strata_prob = NULL, simple = FALSE, strata_var = NULL, clust_var = NULL)
A random sampling declaration, created by
The number of units. N must be a positive integer. (required)
A vector of length N that indicates which stratum each unit belongs to.
A vector of length N that indicates which cluster each unit belongs to.
Use for a design in which n units (or clusters) are sampled. In a stratified design, exactly n units in each stratum will be sampled. (optional)
Use for a design in which either floor(N*prob) or ceiling(N*prob) units (or clusters) are sampled. The probability of being sampled is exactly prob because with probability 1-prob, floor(N*prob) units (or clusters) will be sampled and with probability prob, ceiling(N*prob) units (or clusters) will be sampled. prob must be a real number between 0 and 1 inclusive. (optional)
Use for a design in which strata_n describes the number of units to sample within each stratum.
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.
logical, defaults to FALSE. If TRUE, simple random sampling is used. When simple = TRUE, please do not specify n or strata_n.
# Draw a stratified random sample strata <- rep(c("A", "B","C"), times=c(50, 100, 200)) declaration <- declare_rs(strata = strata) observed_probabilities <- obtain_inclusion_probabilities(declaration = declaration) table(strata, observed_probabilities)#> observed_probabilities #> strata 0.5 #> A 50 #> B 100 #> C 200# Sometimes it is convenient to skip the declaration step observed_probabilities <- obtain_inclusion_probabilities(strata = strata) table(strata, observed_probabilities)#> observed_probabilities #> strata 0.5 #> A 50 #> B 100 #> C 200