I’m interested the impact of gender diversity in small groups. My question is how do I assign students to clusters based on a demographic?
To begin let’s say I have 5 classes each with between 12 and 15 students. In the classes each student has a .3 chance of being female.
pop <- declare_population(class = add_level(N = 5),
students = add_level(N = c(12, 13, 12, 12, 15),
is_female = draw_binary(prob = .3, N = N)))
I now want to assign the students to groups. A group will be considered “treated” if it has at least 1 female, and otherwise will be a control group. I want to maximize the number of treated groups, so almost every treated group should be some combination of MMF
For example a class with 12 students and 3 women, will have a total of 4 triads, of which 3 will be treated.
The groups should be triads if possible and if not possible I should create as many triads as possible and make up the rest in dyads. To do this I wrote the following function which may or may not be helpful:
find_group_size <- function(students){
if(students %% 3 == 1){
n_triads <- floor(students / 3) - 1
n_dyad <- 2
} else if(students %% 3 == 2){
n_triads <- floor(students / 3)
n_dyad <- 1
} else {
n_dyad <- 0
n_triads <- students / 3
}
return(c(rep(3, n_triads), rep(2, n_dyad)))
}
How can I assign students to groups as part of declare_assignment
, in a way to make sure all the female students are in different groups? This may be easier to do as part of declare_population
. Thank you for your help.