Inclusion Probabilities: Cluster Sampling

cluster_rs_probabilities(clust_var, n = NULL, prob = NULL, simple = FALSE,
  check_inputs = TRUE)

Arguments

clust_var

A vector of length N that indicates which cluster each unit belongs to.

n

Use for a design in which n clusters are sampled. (optional)

prob

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

simple

logical, defaults to FALSE. If TRUE, simple random sampling of clusters. When simple = TRUE, please do not specify n.

check_inputs

logical. Defaults to TRUE.

Value

A vector length N indicating the probability of being sampled.

Examples

# Two Group Designs clust_var <- rep(letters, times = 1:26) probs <- cluster_rs_probabilities(clust_var = clust_var) table(probs, clust_var)
#> clust_var #> probs a b c d e f g h i j k l m n o p q r s t u v w x #> 0.5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #> clust_var #> probs y z #> 0.5 25 26
prob_mat <- cluster_rs_probabilities(clust_var = clust_var, n = 10) table(probs, clust_var)
#> clust_var #> probs a b c d e f g h i j k l m n o p q r s t u v w x #> 0.5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #> clust_var #> probs y z #> 0.5 25 26
prob_mat <- cluster_rs_probabilities(clust_var = clust_var, prob = .3) table(probs, clust_var)
#> clust_var #> probs a b c d e f g h i j k l m n o p q r s t u v w x #> 0.5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #> clust_var #> probs y z #> 0.5 25 26