Treatment assignment for one participant group

163 views
Skip to first unread message

Anna Shcherbiak

unread,
Dec 5, 2021, 7:07:06 PM12/5/21
to oTree help & discussion
Hi Chris and others,

I'm designing a study, where participants are randomly assigned to be either Player 1 or Player 2, and then Player 2 can be assigned different levels of the endowment. So we have the following structure: 
  • Player 1
  • Player 2
    • High endowment 
    • Mid endowment 
    • Low endowment
It seems like I know how to assign participates to be either Player 1 or Player 2, but not sure how to layer in this endowment component for Player 2. I thought maybe I could combine the factorial treatment approach, but it doesn't seem to be the correct way to think about this: 

def creating_session(subsession: Subsession):
       players = subsession.get_players()
for p in players:
       p.is_employee = p.id_in_group % 2 > 0
       p.is_boss = p.id_in_group % == 0 

import itertools
treatments = itertools.cycle(
        itertools.product([50, 100, 150])
for p.is_employee in subsession.get_players():
      p.endowment = next(treatments)

Thank you so much! Any guidance would mean the world to me!

Anna

Chris @ oTree

unread,
Dec 5, 2021, 10:18:35 PM12/5/21
to oTree help & discussion
The for loop needs to be written like this:

for in subsession.get_players():
    if p.is_employee:
      p.endowment = next(treatments)

By the way, you don't need 2 fields (is_employee and is_boss). Just use one of them, e.g. "if not p.is_boss" means it's an employee.

Anna Shcherbiak

unread,
Dec 9, 2021, 2:23:10 PM12/9/21
to oTree help & discussion

Thank you so much, Chris!

If I have multiple rounds in my experiment, should I be worried about participants being assigned a different role in each round or does intertools.cycle take care of that?

Thanks!
Anna

Chris @ oTree

unread,
Dec 9, 2021, 2:54:29 PM12/9/21
to oTree help & discussion
Reply all
Reply to author
Forward
0 new messages