Z Tree Slides
Z Tree Slides
Z Tree Slides
Web Resources
z-Tree
zTree hompage
http://www.iew.unizh.ch/ztree/index.php
zTree Wiki
https://www.uzh.ch/iew/ztree/ssl-dir/wiki/
zTree mailing list
send email to majordomo@id.uzh.ch with subscribe ztree_l in
the message body
Background
z-Tree
Add Stages
z-Tree
Each stage corresponds
(roughly) to one screen.
In this case we need 2
stages:
Decision stage.
Results stage.
Add Stages
z-Tree
Programs
z-Tree
Programs can be executed at
the beginning of a stage and
when buttons are clicked.
Calculations are performed
by z-Tree and then sent to
the z-Leafs.
Programs are executed row
by row (i.e. subject by
subject).
Table functions
z-Tree
Syntax 1: table function( expression )
Example: Profits in the public goods game:
subjects.do{
SumContribute = sum(Contribute);
N = count( );
GroupProfit = EfficiencyFactor * SumContribute / N;
Profit = Endowment - Contribute + GroupProfit;
}
Example: Maximum contribution
subjects.do{
MaxContribute = maximum(Contribute);
}
Table functions
z-Tree
Syntax 2: table function( condition, expression )
Example: Sum of all the contributions that exceed 10
subjects.do{
SumHighContribute = sum(Contribute > 10, Contribute );
}
Example: Subject who contributed the least
subjects.do{
CheapSubject = find(Contribute == minimum(Contribute), Subject );
}
Groups
z-Tree
The variable Group determines the group matching.
The number of groups can be set in the background stage.
There are menu commands for different types of matchings
(treatment menu):
Partner
Stranger
absolute Stranger
typed absolute Stranger
Important:
Before running an experiment, check the Parameter table
(treatment menu).
Groups
z-Tree
Same
z-Tree
same( ) can be used to make group calculations
Example: Profits in the public goods game:
subjects.do{
SumContribute = sum( same(Group), Contribute );
N = count( same(Group) );
GroupProfit = EfficiencyFactor * SumContribute / N;
Profit = Endowment - Contribute + GroupProfit;
}
Scope Operator
z-Tree
Alternatively, one can use the scope operator.
Sum contributions of all group members.
subjects.do{
SumContribute = sum(Group == :Group, Contribute );
}
Scope Operator
z-Tree
Building a ranking: incorrect
subjects.do{
RankContribute = count(Contribute <= Contribute);
}
Building a ranking: correct
subjects.do{
RankContribute = count(Contribute <= :Contribute);
}
Examples
z-Tree
Public goods exp
Contribution
decision
Profit display
Ultimatum game
Proposer offer
waiting
waiting
Responder
acceptance
Proposer profit
display
Responder
profit display
Simultaneous stages
Types
z-Tree
We need to assign types to players.
One proposer and one responder per group (randomly allocated)
subjects.do{
RndNum = random();
}
subjects.do{
RndOther = find(same(Group) & not( same(Subject) ) , RndNum);
Proposer = if( RndOther > RndNum, 1, 0);
}
Or easier ... You can also do this in the parameter table (less flexible)
period parameters, subject parameters, period subject parameters
Participate
z-Tree
The variable Participate can be
used to select who enters a stage.
Enter stage: Participate = 1.
Skip stage: Participate = 0.
For the ultimatum game we use:
Participate = if (Proposer == 1, 1, 0);
Additionally:
For the input of the responders
decision we can use radio buttons:
!radio: 0=Reject; 1=Accept;
z-Tree
Stage:
start options
No Risk
High Risk
9,9
0,3
0,5
Low Risk
3,0
6,6
3,5
No Risk
5,0
5,3
5,5
Arrays
z-Tree
To calculate payoffs:
if(Action == 1) {
Profit = if( ActionOther == 1,
Pay11, if( ActionOther == 2,
Pay12, Pay13 ) );
}
Easier:
array Pay1[3];
if(Action == 1) {
Profit = Pay1[ActionOther];
}
Boxes
z-Tree
Box = rectangular area of the screen containing stuff
Boxes are positioned over each other.
standard box
header box
help box
grid box
history box
Boxes
z-Tree
Container Box = rectangular area containing other boxes
Very useful
move many boxes at the same time
Keep things in place with different resolutions
800p
600p
Boxes
z-Tree
Distances can be set as % of the screen or in pixels
Display condition
Used to make boxes appear (when true) or disappear (when false)
Boxes
z-Tree
Example
Contracts table
z-Tree
Table has a flexible number of records (records can be added).
New records are created in contract creation boxes.
or with the new command: contracts.new{ x=1; }
Buyer
Bid
Order
Remark
Contracts table
z-Tree
Table has a flexible number of records (records can be added).
New records are created in contract creation boxes.
or with the new command: contracts.new{ x=1; }
Buyer
Bid
Order
10
Remark
Subject 2 makes a bid (highest bid)
Contracts table
z-Tree
Table has a flexible number of records (records can be added).
New records are created in contract creation boxes.
or with the new command: contracts.new{ x=1; }
Buyer
Bid
Order
Remark
10
12
Contracts table
z-Tree
Table has a flexible number of records (records can be added).
New records are created in contract creation boxes.
or with the new command: contracts.new{ x=1; }
Buyer
Bid
Order
Remark
10
12
15
Contracts table
z-Tree
Table has a flexible number of records (records can be added).
New records are created in contract creation boxes.
or with the new command: contracts.new{ x=1; }
Buyer
Bid
Order
Remark
10
12
15
17
Contracts table
z-Tree
The contents of the
contracts table can be
displayed with a
contracts list box or
with a contracts grid
box.
Other Features
z-Tree
Programming
Loops: while( condition ) { statements; }
Complex move structures
goto next stage if
Treatments with indefinite length
end with a given probability
end when a specific action is taken
Graphics
Charts
Display Pictures/Videos
Communication
Chat box
Questionnaires
z-Tree
Must be run so that the payoff file is written.
Questions with no consequence on payoff.
Different formats for the questions.
Layout is not screen oriented: indefinite end with scrollbar.
Text entry possible.
Typical Questionnaires:
Address form (writes the payment file)
Questions concerning their strategies
Profit display
Goodbye screen