A Course in z-Tree


3: Roles, Matching, Values, Repetitions



Matteo Ploner
Università degli Studi di Trento

General Parameters


  • Define two important dimensions of the experiment
    • Number of participants
    • Number of repetitions of the task (Periods)
  • Just click on "Background" (tree icon)


☝ zTree will re-run all your code for the # of paying periods specified

Roles


  • TASK: assign some to role Green and some to role Blue
    • Generally, allocation is random

Roles (1)


Assignment is made according to Subject variable

									//Role=1: BLUE; Role=0: GREEN

									// we use the modulus function

									//even Subjects are BLUE, odd Subjects are GREEN

									Role=mod(Subject,2);
					
  • The mod function computes the remainder after dividing the first elment by the second one (Euclidean division)
  • e.g., mod(4,3) returns 1; mod (2,3) returns 2; mod(3,3) returns 0 ...

Roles (2)


Assignment is made according to Subject variable


									//Role=1: BLUE; Role=0: GREEN

									// we use the modulus function

									//first half is BLUE, other half GREEN

									Role=if(Subject<=(maximum(Subject)/2),1,0);
								

Roles (3)


Assignment is NOT made according to Subject variable


									//Role=1: BLUE; Role=0: GREEN

									rank_rdm=random();
							

Next portion of code should go in a different Program!


									// we assign a random number between 1 and N to each

									rank = subjects.count( rank_rdm<= :rank_rdm);

									//Role=1: BLUE; Role=0: GREEN

									//even Subjects are BLUE, odd Subjects are GREEN

									Role=mod(rank,2);
							

Values


  • TASK: assign to some a certain value conditional upon their role
    • The green get value X, the blue get value Y

Values (2)


Assign an endowment according to the role


									//we assign to those with Role==1 (BLUE) 100 Endowment and to the others 0

									Endowment=if(Role==1,100,0);
							

Values (3)


  • TASK: assign to everyone the same random value $\in \{0...100\}$

Values (4)


First we create the value in globals
Then we reterieve it to subjects


									common_value=round(random()*100,1);

									common_value=globals.find(common_value);
							

  • This can be very useful to
    • induce some common random shock
    • select a common period for payment
    • randomly end the experiment

Matching


  • TASK: group participants into interacting groups
    • 3 groups of 4
      • 2 blues and 2 greens in each group

Matching


Create homogenous groups
First, assign a random number


									group_rdm=random();

									Endowment=if(Role==1,100,0);
							

Then, assign them a Group code


									rank = subjects.count(Role==:Role & rank_rdm<= :rank_rdm);

									Group = mod(rank,maximum(Subject)/4);
							

Repetitions


  • How are participants going to interact?
    • Partner or stranger?

Matching over repetitions


Define the type of matching
  • Partner
    • 
      													if (Period>1){
      														Group=OLDsubjects.find(same(Subject),Group);
      													}else{
      														Group=Group;
      													}
      											

  • (Random) Stranger
    • Just run the code for Group formation in each Period!

Parameter Table


  • The matching can be done via the Parameter table
  • However ...
    • Static approach that does not handle changes in periods and number of subjects
    • Boring to compile

Assignment




  1. Create an experiment with 4 participants
    • Match them in 2 groups of 2 (using the parameter table)
    • Assign 1 participant in each group to role 1 and the other to role 2
    • Give an endowment of 100 to those in role 1 and 50 to those in role 2
    • Repeat the interaction 10 $\times$ with roles and group composition fixed (partner matching)
    • Each round display to participants the role and the endowment
  2. Repeat the same experiment without using the parameter table