Random assignment to treatment for the whole group

73 views
Skip to first unread message

Gøril Andreassen

unread,
Nov 22, 2021, 11:31:38 AM11/22/21
to LIONESS Lab help and discussion
Hi,
Thank you very much for developing Lioness.

I have groups with three players in each and would like to randomly assign the different groups to 3 different treatments. The whole group get the same treatment.

If I just write 
if (period == 1){
treatment = 1 + (groupNr-1) % 3;
  record('treatment', treatment);
 } 
the treatment assignment is not random, but deterministic.

I tried to assign one player in the group to a treatment first and then the others in the group get the same treatment, but with the code I used some groups got different treatment. This is the code:

function ff() {
let treatment = getValuesOthers('firstTreatment').find(t => typeof t == 'number');
if (treatment > 0) {
return treatment;
} else {
treatment = 1 + Math.floor(Math.random()*3);
record('firstTreatment', treatment);
return treatment;
}
}

if (period ==1){
treatment = ff();
record('treatment', treatment);
}

if (period >1){
treatment = getOldValue('treatment', treatment);
record('treatment', treatment);

Thank you for any help!

Best, Gøril

Jose Guinot Saporta

unread,
Nov 22, 2021, 11:47:48 AM11/22/21
to Gøril Andreassen, LIONESS Lab help and discussion
Hello Gori,
 
you are having problems because you check a value that is decided in the same stage. Some participants are going to execute the else of your condition because the first one has not completed the record('firstTreatment', treatment); instruction yet (or the database is not updated yet).
My suggestion is that every subject 1 does the random treatment assignation and subjects 2 and 3 check this value in the following stage.

Best regards,
Jose


From: lione...@googlegroups.com <lione...@googlegroups.com> on behalf of Gøril Andreassen <goril.l.a...@gmail.com>
Sent: 22 November 2021 16:31
To: LIONESS Lab help and discussion <lione...@googlegroups.com>
Subject: Random assignment to treatment for the whole group
 
--
You received this message because you are subscribed to the Google Groups "LIONESS Lab help and discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lioness-lab...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/lioness-lab/f7288744-3b80-4bc9-b543-69ad7189008en%40googlegroups.com.

This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please contact the sender and delete the email and
attachment. 

Any views or opinions expressed by the author of this email do not
necessarily reflect the views of the University of Nottingham. Email
communications with the University of Nottingham may be monitored 
where permitted by law.



Gøril Andreassen

unread,
Nov 23, 2021, 3:44:04 AM11/23/21
to LIONESS Lab help and discussion
Hi Jose,
Thank you, that worked! Next questions: How can I ensure that 1/3 of the groups get one treatment and 1/3 of the group get the other treatments?

Thank you very much!

Best, Gøril

Jose Guinot Saporta

unread,
Nov 23, 2021, 4:00:26 AM11/23/21
to Gøril Andreassen, LIONESS Lab help and discussion
Hello Gori,

That is the reason I like more your first design. The order your participants connect to the experiment is random enough and you know that the treatment assignment will be balanced.

If you want to go ahead with the random function you can check if the number of participants assigned to each treatment is not bigger than the maximum. If it is bigger or equal, then you assign them to the other treatments.  If you do this dynamically you can adjust the maximum for each treatment to the average of the other two treatments plus an offset.

Best regards,
Jose

Sent: 23 November 2021 8:44

To: LIONESS Lab help and discussion <lione...@googlegroups.com>
Subject: Re: Random assignment to treatment for the whole group
 

Gøril Andreassen

unread,
Nov 23, 2021, 4:29:29 AM11/23/21
to LIONESS Lab help and discussion
Thank you again, Jose.

How do I sum up the number of participants that are assigned to a treatment?

Best, Gøril

Reply all
Reply to author
Forward
0 new messages