oTree Forum >

Group by role and treatment

#1 by april30

Hi all,
I am grouping my participants based on roles and treatment condition. 
I know we can keep them in the same role by using the 
subsession.group_randomly(fixed_id_in_group=True)argument, but how can I also make sure to match the treatment people together and the control condition people together? Thanks so much!

#2 by BonnEconLab

One way that works for sure is to manually set the “group matrix” according to your criteria:


If I understand you correctly, your group structure would be, for instance, half of the participants are treated, half are in the control condition. Say, you have 8 participants: 1–4 are in the treatment group, 5–8 are in the control group. Moreover, let’s assume that the odd IDs take on Role A, and the even IDs take on Role B.

You could then use

def creating_session(subsession):

    TC_matrix = [
        [[1, 2], [3, 4]], [[5, 6], [7, 8]],
        [[1, 4], [3, 2]], [[5, 8], [7, 6]],
    subsession.set_group_matrix(TC_matrix[subsession.round_number - 1])

#3 by april30

Thank you so much for replying. I guess I will have to manually do it :)

Write a reply

Set forum username