oTree Forum >

Block Randomising Treatment

#1 by lindk (edited )

Hi all,

I am trying to randomise balanced treatments over two blocks, but I seem to be stuck. I am creating a single player experiment and have 4 treatment settings called "red_bettopp_s", "red_worseopp_s", "cap_bettopp_s" and "cap_worseopp_s". I am trying to create two balanced treatment groups on the participants' birth region (Eastern Europe, Western Europe) - meaning I would like to loop my treatments over the participants who enter Eastern Europe as their region of birth and those who enter Western Europe seperately. This way I want to ensure that the treatments are not only balanced over the treatment settings, but also the same amount of participants born in Eastern Europe and Western Europe are represented in each treatment.

Here is the code I have so far - it does not include the origin region yet, which is stored as a participant field called 'origin':

from itertools import cycle
def gen_treatment(player):
    participant = player.participant
    subsession = player.subsession
    treat = cycle(['red_bettopp_s', 'red_worseopp_s', 'cap_bettopp_s', 'cap_worseopp_s'])
    for player in subsession.get_players():
       participant.treat_groups_s = next(treat)
 class Pre_PolAttViews(Page):
    def before_next_page(player: Player, timeout_happened):

Any help on this is greatly appreciated! 

Write a reply

Set forum username