random_period=roundup(random()*NumPeriods,1);
TOT_contribution=subjects.sum(same(Group),contribution);
//here we compute the payoffs
Payoff=endowment-contribution+TOT_contribution*gain;
//find the best among others
top_other_group=subjects.maximum(same(Group) & not(same(Subject)),contribution);
//find the worst among others
low_other_group=subjects.minimum(same(Group) & not(same(Subject)),contribution);
//find the median among others (smart way)
median_other_group=TOT_contribution-contribution-low_other_group-top_other_group;
//write the relevant data in a table
summary.new{
Period=:Period;
Subject=:Subject;
Payoff=:Payoff;
}
Participate=if(Period==NumPeriods,1,0);
//selected period
selected_period=globals.find(random_period);
Final_payment=summary.find(same(Subject) & Period==selected_period,Payoff);
Choice of the other | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | |
Your choice |
A z-Tree course: PGG
Matteo Ploner