strata_and_cluster_rs_probabilities: Inclusion Probabilities: Stratified and Clustered Random...

Description Usage Arguments Value Examples

Description

Inclusion Probabilities: Stratified and Clustered Random Sampling

Usage

1
2
3
strata_and_cluster_rs_probabilities(strata = NULL, clusters = NULL,
  prob = NULL, prob_unit = NULL, n = NULL, n_unit = NULL,
  strata_n = NULL, strata_prob = NULL, check_inputs = TRUE)

Arguments

strata

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

clusters

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

prob

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

prob_unit

Must of be of length N. tapply(prob_unit, blocks, unique) will be passed to strata_prob.

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.

n_unit

Must be of length N. tapply(m_unit, blocks, unique) will be passed to strata_n.

strata_n

Use for a design in which 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
clusters <- rep(letters, times = 1:26)

strata <- rep(NA, length(clusters))
strata[clusters %in% letters[1:5]] <- "stratum_1"
strata[clusters %in% letters[6:10]] <- "stratum_2"
strata[clusters %in% letters[11:15]] <- "stratum_3"
strata[clusters %in% letters[16:20]] <- "stratum_4"
strata[clusters %in% letters[21:26]] <- "stratum_5"

table(strata, clusters)

probs <- strata_and_cluster_rs_probabilities(strata = strata,
                                         clusters = clusters)

table(probs, strata)
table(probs, clusters)


probs <- strata_and_cluster_rs_probabilities(clusters = clusters,
                                         strata = strata,
                                         prob = .5)

table(probs, clusters)
table(probs, strata)

probs <- strata_and_cluster_rs_probabilities(clusters = clusters,
                                         strata = strata,
                                         strata_n = c(2, 3, 2, 3, 2))

table(probs, clusters)
table(probs, strata)

probs <- strata_and_cluster_rs_probabilities(clusters = clusters,
                                         strata = strata,
                                         strata_prob = c(.1, .2, .3, .4, .5))

table(probs, clusters)
table(probs, strata)

DeclareDesign/randomizr documentation built on June 2, 2019, 3:50 p.m.