DeclareDesign / randomizr

randomizr: Easy-to-Use Tools for Common Forms of Random Assignment and Sampling
https://declaredesign.org/r/randomizr
Other
37 stars 9 forks source link

fixed number of units per stratum block? #22

Closed acoppock closed 7 years ago

acoppock commented 7 years ago

Proposed syntax for sampling

strata_var <- rep(c("A", "B","C"), times = c(50, 100, 200))
S <- strata_rs(strata_var = strata_var, n = 10)
table(strata_var, S)

10 As, 10 bs, 10 cs.

for random assignment

block_var <- rep(c("A", "B","C"), times = c(50, 100, 200))
Z <- block_ra(block_var = block_var, m = 10)
table(strata_var, Z)

treat 10 of 50 As, 10 of 100 Bs, etc.

acoppock commented 7 years ago

Need to consider implications for inferring designs in declare_ra or declare_rs

graemeblair commented 7 years ago

This would be great, if it doesn't screw up declare_ra/declare_rs as you raise.

acoppock commented 7 years ago

fixed in 51d273366b016a786b0037342d3b9b08e43ac9c1

strata_var <- rep(c("A", "B","C"), times = c(50, 100, 200))
Z <- strata_rs(strata_var = strata_var, n = 20)
table(strata_var, Z)

with result:

> table(strata_var, Z)
          Z
strata_var   0   1
         A  30  20
         B  80  20
         C 180  20