I want to try using DeclareDesign for blocking on multiple variables. One way to do this as shown here.
Say my population is 100 people, and I want to block on
p <- declare_population(N = 100, gender = rbinom(N, 1, prob = .5), eye_color = sample(c("blue", "green", "brown"), N, replace=TRUE, prob = c(.2, .2, .6)))
One way to block of both vars at the same time is to create a single variable that encapsulates both vars.
My intuition as a
dplyr user is to do something like:
population <- p() %>% unite(block, gender, eye_color, remove = FALSE)
but I realize that this doesn’t follow the DeclareDesign framework. A more DeclareDesign approach would be to do something like:
d <- declare_step(block = paste(gender, eye_color, sep = "_"), handler = fabricate)
From here on
delcare_assignment is straight forward…
However I also realize that from Jasper’s other answer that
blockTools might be a superior solution to take this on, but from my cursory understanding I am not sure how it plays into the DeclareDesign framework.
My questions are:
Is it bad to tackle this question the dplyr way or is there some reason should I really be using
Is the method of creating one variable eventually going to limit my designs, and should I be using blockTools instead? If so, how would I use blockTools together with DeclareDesign?