Random Treatment Assignment

115 views
Skip to first unread message

Marcel Seifert

unread,
Sep 23, 2020, 5:51:34 AM9/23/20
to LIONESS Lab help and discussion
Dear Lioness-Team, 

I am trying to randomize the treatment assignment but I am facing a problem with getting the values of an array that i saved. 

in short, player 1 should save an array with the randomly shuffled 12 treatments and all other players should draw their role from this array. 
 
In practice I did it like this: 

STAGE 1: 
if(playerNr==1){
treatments=['1','2','3','4','5','6','7','8','9','10','11','12']; 
treatments=shuffle(treatments);
record('treatments', treatments)
-----

STAGE 2: 
refPl=1; 
treatments=getValue('decisions', 'period='+period+' and playerNr='+refPl, 'treatments');
role=treatments[playerNr-1];
-------

However, at stage 2 drawing from the treatments array does not work as it somehow not saved as it looks in stage 1. 

I tried it with .join() but then the role=treatments[playerNr-1] does not work as it counts also the comma. 

Do you have any idea how to solve this?
Thanks and best regards, 
Marcel


Marcel Seifert

unread,
Sep 23, 2020, 2:22:53 PM9/23/20
to LIONESS Lab help and discussion
Okay i found a solution that i can share if at some point faces the same question.
 
In stage 1, a random number between 1 and 10 is drawn by player 1. 
In stage 2, there are 10 already shuffled arrays with the treatments. The random number from stage 1 will be used by all players to determine which array of treatments will be played in the session.

Thomas Dudek

unread,
Mar 23, 2021, 7:58:29 PM3/23/21
to LIONESS Lab help and discussion
Hi Marcel,

I am trying something similar but with only 4 treatments.
do you have your experiment in a repository where I could access it to see how you solved this exactly?
Your own description here doesn't fully explain to me what you did to solve the random treatment assignment.

Thanks,
Thomas

Marcel Seifert

unread,
Mar 24, 2021, 6:36:20 AM3/24/21
to LIONESS Lab help and discussion
Hi Thomas, 

thanks for your message. 
I uploaded the two relevant stages for the random assignment in the repository named "randomize_for_thomas_dudek"

Its basically done as follows: 
On Stage 1, a random number "treatmentArray" between 1 and 10 is drawn. 
On Stage 2, this number determines which of the 10 randomly shuffled treatment arrays is used. Based on the playerNr, the role of the participant is then drawn from the chosen array. 

Hope this helps, 
Best
Marcel

Thomas Dudek

unread,
Apr 6, 2021, 12:56:32 AM4/6/21
to LIONESS Lab help and discussion
Thank you Marcel! 
I have only seen your message very late and used a different solution ultimately. It's also a little less code and easier to understand for someone without any Javascript knowledge -- like me.
Cheers,
Thomas
Reply all
Reply to author
Forward
0 new messages