Z-Tree Lecture_notes_handout.pdf

download Z-Tree Lecture_notes_handout.pdf

of 214

Transcript of Z-Tree Lecture_notes_handout.pdf

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    1/214

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    2/214

    Getting started

    Introduction

    Installing z-Tree

    Structure of az-Tree treatment

    Part I

    Getting started

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    3/214

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    4/214

    Getting started

    Introduction

    Installing z-Tree

    Structure of az-Tree treatment

    Pros and Cons of computerized

    experiments

      Pros:

    1.   speed2.   reliability and ease of data collection

    3.   replicability4.   new possibilities

      Cons:

    1.  some subjects pools may have problems usingcomputers2.  need to run the experiment in a room, with the

    necessary equipment

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    5/214

    Getting started

    Introduction

    Installing z-Tree

    Structure of az-Tree treatment

    Structure of a typical session I

    1.   Subjects arrival check subjects on the list pay and send home supernumerary subjects (if 

    any) randomly assign subjects to workstations

    2.   Instructions hand out written instructions read instructions out loud

    question time control questions (possibly computerized)

    3.  Bathroom break

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    6/214

    Getting started

    Introduction

    Installing z-Tree

    Structure of az-Tree treatment

    Structure of a typical session II

    4.  Trial periods (optional)

    5.   Treatment(s)

    6.  Questionnaire (computerized, if possible)

    7.   Payment must be individual and anonymous check out all the bureaucratic requirements

    (receipts, copies of the documents, etc.)

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    7/214

    Getting started

    Introduction

    Installing z-Tree

    Structure of az-Tree treatment

    How can z-Tree help you?

    1.   Control questions:

    record how many times a subject gives the wronganswer

    measure how long it takes for a subjects tocomplete the control question

    2.   Treatment(s)

    3.   Questionnaires

    4.   Payment manage losses add show-up fee round earnings prepare simple receipts

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    8/214

    Getting started

    Introduction

    Installing z-Tree

    Structure of az-Tree treatment

    How does z-Tree work?

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    9/214

    Getting started

    Introduction

    Installing z-Tree

    on your PC

    command-lineoptions

    on a file server

    Without a fileserver

    Test the

    installation

    Structure of az-Tree treatment

    Installing z-Tree on your PC

    Simply put zLeaf.exe and zTree.exe in the same   folder,on your pc.

    Command-line options:

    1.  create a shortcut tozTree.exe or to zLeaf.exe

    2.  add the desired options

    in the “target” field.

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    10/214

    Getting started

    Introduction

    Installing z-Tree

    on your PC

    command-lineoptions

    on a file server

    Without a fileserver

    Test the

    installation

    Structure of az-Tree treatment

    z-Leaf command-line options

    “/name”  to create shortcuts to different clients on

    the same computer (useful for testing).   /name zleaf1   /name zleaf2   ...

    “/language”  to change the language used in the clients’interface.

      /language en   /language de   ...

    For the full list of options, see the z-Tree referencemanual, at pp. 57-59.

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    11/214

    Getting started

    Introduction

    Installing z-Tree

    on your PC

    command-lineoptions

    on a file server

    Without a fileserver

    Test the

    installation

    Structure of az-Tree treatment

    Batch filesTo make things simpler, you can

     download and extract Ernesto Reuben’s zip file:http://www.ereuben.net/teach/

    zTreeTestEnvironment.zip

     place the executables zTree.exe and zLeaf.exe in the

    “program” sub-folder   launch z-Tree with the batch file: “openztree.bat”

      launch as many z-Leaves as you need using the file

    “Open Zleafs.exe”.

    http://www.ereuben.net/teach/zTreeTestEnvironment.ziphttp://www.ereuben.net/teach/zTreeTestEnvironment.ziphttp://www.ereuben.net/teach/zTreeTestEnvironment.ziphttp://www.ereuben.net/teach/zTreeTestEnvironment.zip

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    12/214

    Getting started

    Introduction

    Installing z-Tree

    on your PC

    command-lineoptions

    on a file server

    Without a fileserver

    Test the

    installation

    Structure of az-Tree treatment

    Installing z-Tree on a file server

    1.  put the files z-Tree.exe and z-Leaf.exe in a singledirectory on the file server

    2.  make sure you have read/write permissions  onthis directory  and on the parent directory

    3.  make sure clients have read permissions on the

    directory

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    13/214

    Getting started

    Introduction

    Installing z-Tree

    on your PC

    command-lineoptions

    on a file server

    Without a fileserver

    Test the

    installation

    Structure of az-Tree treatment

    Installing z-Tree without a file server  Z-Tree and z-Leaf can run on different computers

    that do not have access to a common file server(e.g. to run experiments over the Internet).

     You need to run zLeaf with the command lineoption “/server”

    e.g.   /server 169.252.196.239 where 169.252.196.239 is the ip address of the

    computer where zTree is running

     To know a computer’s ip address open the windows’

    shell and type   ipconfig

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    14/214

    Getting started

    Introduction

    Installing z-Tree

    on your PC

    command-lineoptions

    on a file server

    Without a fileserver

    Test the

    installation

    Structure of az-Tree treatment

    Testing z-Treez-Tree starts with one untitled treatment.

    You can change the default language from the menuTreatments→Language  before creating a newtreatment.

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    15/214

    Getting started

    Introduction

    Installing z-Tree

    on your PC

    command-lineoptions

    on a file server

    Without a fileserver

    Test the

    installation

    Structure of az-Tree treatment

    Testing z-Leaf I

    z- Leaf starts only if z-Tree is running.

    By default, it starts as a full-screen window.   Press  Alt+F4 to close it,

      Alt+Tab to switch to a different window.

    G i d

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    16/214

    Getting started

    Introduction

    Installing z-Tree

    on your PC

    command-lineoptions

    on a file server

    Without a fileserver

    Test the

    installation

    Structure of az-Tree treatment

    Testing z-Leaf IIWhen you start a “leaf” (i.e. a new client), you can alsosee it from the server program z-Tree.

    Select  Run→Clients Table from the menu at the top.

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    17/214

    Individual Decision

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    18/214

    Individual DecisionMaking

    Plan of thetreatment

    Background

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Part II

    Individual Decision Making

    Individual Decision

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    19/214

    Individual DecisionMaking

    Plan of thetreatment

    Background

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Individual Decision MakingPlan of the treatment

    Background

    ProgramsBackground screen

    StagesScreen layout

    BoxesItems

    Item layout optionsButtonsResults

    Testing the treatment

    Questionnaires

    Data files

    Exercise 1

    Individual Decision

    E l l

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    20/214

    Individual DecisionMaking

    Plan of thetreatment

    Background

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Example: lottery

      endowment:   E 

      the lottery yields: x (1 + a) with probability  p  0 with probability 1 − p 

      task: choose  x  between 0 and  E 

      random draw:   n  between 0 and1

      payoff:   E  − x  + I [n ≤ p ]x (1 + a)

    see lottery.ztt

    Individual Decision

    Pl f h

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    21/214

    Individual DecisionMaking

    Plan of thetreatment

    Background

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Plan of the treatment

    1.   Background:  set the value of the variables global variables:  same value for all subjects  →

    E ,  p ,  a “subject” variables:  possibly different values for

    different subjects  →  x ,  n

    2.   Stage 1:  subjects make their choice  → x

    3.   Stage 2:   results

    compute subjects’ payoffs (in a program, at thebeginning of the stage) show each subject his/her payoff on the screen (in

    the “Active screen” of the stage)

    Individual Decision

    B k d

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    22/214

    uMaking

    Plan of thetreatment

    BackgroundPrograms

    Backgroundscreen

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Background

    Individual Decision

    P I

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    23/214

    Making

    Plan of thetreatment

    BackgroundPrograms

    Backgroundscreen

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Programs - ISet the global variables

     select the last table listed in the Background(logfile)

     from the menu, choose  treatment→  new program(crtl+alt+p)

     choose “globals” in the field  Table

      use  //  to insert comments

    Individual Decision

    P II

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    24/214

    Making

    Plan of thetreatment

    BackgroundPrograms

    Backgroundscreen

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Programs - IISet the “subject” variables

     Create another program which runs on the subjects

    table

    Note:  here we use the function   random().  This generates a random number from a uniform

    distribution between 0 and 1.

     The random number will be  different   for different 

    subjects .

    Individual Decision

    B k d

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    25/214

    Making

    Plan of thetreatment

    BackgroundPrograms

    Backgroundscreen

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Background screen

    The   Background also contains some information about

    what is displayed on subjects’ screen.In the Active screen a header box is placed by default.

      the   header boxdefines the topof the screen.

      to remove theheader deletethe   header boxfrom the  Active

    screen   in theBackground

    The Waiting screen contains the message shown tosubjects when they have to wait.

    Individual DecisionM kiStages

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    26/214

    Making

    Plan of thetreatment

    BackgroundStages

    Screen layout

    Boxes

    Items

    Item layoutoptions

    Buttons

    Results

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Stages

    Individual DecisionM kiCreate a new stage

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    27/214

    Making

    Plan of thetreatment

    BackgroundStages

    Screen layout

    Boxes

    Items

    Item layoutoptions

    Buttons

    Results

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Create a new stage

    Select the   Background icon, then from the menu,choose:   Treatment →  New Stage (ctrl+alt+s)

     Choose a meaningfulname for the stage (e.g.“Lottery”)

      Set the  timing  (wait forall, start if possible, ...)

      Set the  timeout: choose”No” if you wish to

    record the time withoutforcing subjects to leavethe stage

    Create a second stage named “Results”.

    Individual DecisionMakingthe Active screen

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    28/214

    Making

    Plan of thetreatment

    BackgroundStages

    Screen layout

    Boxes

    Items

    Item layoutoptions

    Buttons

    Results

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    the Active screen

      the   Active screen of a Stage defines theinformation displayed on subjects’ screens

     If you do not want to use the background screen insome stages, click on   Active screen and unmark“Background screen is being used”

      the   Active screen contains  Boxes i.e. rectangles that organize the space on the

    screen

      Boxes contain  Items, which can be pieces of information input fields figures

    etc.

    Individual DecisionMakingScreen layout

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    29/214

    Making

    Plan of thetreatment

    BackgroundStages

    Screen layout

    Boxes

    Items

    Item layoutoptions

    Buttons

    Results

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Screen layout

     Set the dimension and position of each box.  Boxes can overlap

    Individual DecisionMakingCreate a Box

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    30/214

    Making

    Plan of thetreatment

    BackgroundStages

    Screen layout

    Boxes

    Items

    Item layoutoptions

    Buttons

    Results

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Create a Box

      Select   Active Screen in the “Lottery” stage.

     From the menu, select  Treatment→  New Box →Standard Box (ctrl+alt+d)

    Individual DecisionMakingOutput items

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    31/214

    Making

    Plan of thetreatment

    BackgroundStages

    Screen layout

    Boxes

    Items

    Item layoutoptions

    Buttons

    Results

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Output items

    Output items:   to convey information to the subjects.Place output items in the “Choice” box

     select the box “Choice” inthe “Lottery” stage

     from the menu, select

    Treatment→   New Item(ctrl+alt+i)

    Output

     Label: “Your endowment”

      Variable: E  Layout: 1 (0.1 for 1 decimal digit...)

     You can use  < > to insert variable values into labels:Label: “< > Your Endowment:   < E|1> coins.”

    Individual DecisionMakingInput items

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    32/214

    a g

    Plan of thetreatment

    Background

    Stages

    Screen layout

    Boxes

    Items

    Item layoutoptions

    Buttons

    Results

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Input items

    Input items:  to get inputs from subjects.

    Create a new Item (ctrl+alt+i)   Label: “Choose how

    much to invest in thelottery”

      Variable: x  Layout: 1 (0.1 for 1

    decimal digit...)

      check the   Input

    box   Minimum: 0

      Maximum: ENote:  you can use variables here!

    Individual DecisionMakingItem layout

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    33/214

    g

    Plan of thetreatment

    Background

    Stages

    Screen layout

    Boxes

    Items

    Item layoutoptions

    Buttons

    Results

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Item layout

    See the Reference Manual at page 30, and Part 6 for the

    new  !string layout.

    Individual DecisionMakingConfirm an input

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    34/214

    Plan of thetreatment

    Background

    Stages

    Screen layout

    Boxes

    Items

    Item layoutoptions

    Buttons

    Results

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Confirm an input

    Inputs are confirmed by clicking on a button.

    To  add a button   in a box, from the menu, selectTreatment→   New Button (ctrl+alt+b)

    Individual DecisionMakingProfit calculation

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    35/214

    Plan of thetreatment

    Background

    Stages

    Screen layout

    Boxes

    Items

    Item layoutoptions

    Buttons

    Results

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Profit calculationOnce the subjects’ choices have been collected, theprogram should compute the profits.

    Select the “Results” stage, and create a new program.

    Note:  here we use the “if” function:if(condition,T,F)   , which returns value   T   if the “condition” is true   F  if the “condition” is false

    A complete list of available functions at page 45 of the

    Reference Manual.

    Individual DecisionMakingResults screen

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    36/214

    Plan of thetreatment

    Background

    Stages

    Screen layout

    Boxes

    Items

    Item layoutoptions

    Buttons

    Results

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Results screen

    In the   Active Screen of the “Results” stage, create a

    new  Standard Box, and name it “Results”.

     In this box, add an  Item to display the  random

    number   n, with 2 decimal digits.  Add a second Item to display the subject’s  profit.

     Add a Button to end the treatment.

    Individual DecisionMakingTest the treatment I

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    37/214

    Plan of thetreatment

    Background

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    est t e t eat e t

    To set the  general parameters:  Double-click on the

    Background   icon (thevery first line of the

    program) to set thegeneral parameters.

      Exchange rate  = 1/n if n points equal 1 Euro.

    To start the test, launch z-Leaf.exe and check theconnection from z-Tree, in the Clients Table.

    Individual DecisionMakingTest the treatment II

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    38/214

    Plan of thetreatment

    Background

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    From the z-Tree menu,

      select  Run→  Start treatment (or press F5)

      select  Run→   Stop clock (or press F12) to stopthe time from running,

      select  Run→   Restart clock (or press Shift+F12)to restart the time,

      select  Run→   subjects table to monitor thesubjects activity.

    Individual DecisionMakingTest the treatment III

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    39/214

    Plan of thetreatment

    Background

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    To  stop the execution of a treatment:

    1.  From the menu, choose  Run→Stop after thisperiod.

    2.  Open the clients table (Run→Clients table),then click at the top of the second column(”state”), so to select it all.

    3.  From the menu, choose  Run→Leave stage, until

    all clients are marked as ”ready”.

    Individual DecisionMakingTest the treatment IV

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    40/214

    Plan of thetreatment

    Background

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Individual DecisionMakingQuestionnaires

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    41/214

    Plan of thetreatment

    Background

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    A questionnaire is needed to generate  payment file.   select  File→  New

    questionnaire   select   Questionnaire→

    Language  and select thelanguage of your choice

      select   Questionnaire→New address form

      select   Questionnaire→New question form and

    name it “Empty”The  Address Form is needed, but if you leave the fieldsFirst Name and  Last Name empty the Address formwill not be displayed. To start the questionnaire, select

    Run→  Start questionnaire (or press F5)

    Individual DecisionMakingFiles saved by z-Tree

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    42/214

    Plan of thetreatment

    Background

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Session data are saved in the directory containingz-Tree.exe:

    .pay:  the payment file, whichlists the subjects’ finalprofits including theshow-up fee

    .adr:   subjects’ addresses(from the Questionnaire)

    .sbj:  answers to questionnaire’s questions, without

    subjects’ names.gsf:  backup file, in case a crash occurs

    .xls:  contains all tables used in a session (subjects table,globals table, etc)

    Individual DecisionMaking.pay and .xls files

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    43/214

    Plan of thetreatment

    Background

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    The payment file  (.pay):

    The data file  (.xls):

    Individual DecisionMakingHow to use z-Tree data

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    44/214

    Plan of thetreatment

    Background

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    Option 1:  From the menu select  Tools→   Separate

    tables. Select the .xls file generated byz-Tree and select  Open. This generates one.xls file per each of the tables used in thesession.

    Option 2:  for those who use  Stata, Kan Takeuchideveloped an .ado file to import z-Tree datadirectly into Stata.www.econ.hit-u.ac.jp/~kan/

    research/ztree2stata/index.html

    Option 3:  for those who use  R, Oliver Kirchkampdeveloped a utility to import data fromz-Tree into R. download.www.kirchkamp.de/lab/zTree.html

    Individual DecisionMakingExercise 1: guess

    http://www.econ.hit-u.ac.jp/~kan/research/ztree2stata/index.htmlhttp://www.econ.hit-u.ac.jp/~kan/research/ztree2stata/index.htmlhttp://www.econ.hit-u.ac.jp/~kan/research/ztree2stata/index.htmlhttp://www.econ.hit-u.ac.jp/~kan/research/ztree2stata/index.htmlhttp://www.kirchkamp.de/lab/zTree.htmlhttp://www.kirchkamp.de/lab/zTree.htmlhttp://www.econ.hit-u.ac.jp/~kan/research/ztree2stata/index.htmlhttp://www.econ.hit-u.ac.jp/~kan/research/ztree2stata/index.html

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    45/214

    Plan of thetreatment

    Background

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    see z-Tree Tutorial, page 25.

    Subjects have to make a calculation.They have to calculate the sine function for a randomlydetermined value: sin(C*A/B)Subjects are paid according to the precision of their

    guess:  Profit (in points):

    100 ∗ (1 − |sin(C  ∗ A/B ) − guess |)

     A and B are random integer numbers between 1 and

    10. They take different values for different subjects.  C is equal to  π   (3.14...)

    Individual DecisionMakingExercise 1: details

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    46/214

    Plan of thetreatment

    Background

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

     Subjects cannot make negative profits (set the

    profit function accordingly).  Do not include the header, nor the alert frame.

     Layout of the input variable: slider.

     Functions you need to use: abs(): absolute value  max(x,y): returns the maximum value between x

    and y pi(): returns 3.1415...

    roundup(x,y): returns the smallest multiple of ythat is greater or equal to x. sin(x): returns the sine of x.

    Solution: exercize 1.ztt

    Individual DecisionMakingExercise 1 - layout

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    47/214

    Plan of thetreatment

    Background

    Stages

    Testing thetreatment

    Questionnaires

    Data files

    Exercise 1

    One-shotTwo-player Games

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    48/214

    One shot games

    Exercise 2

    Part III

    One-shot Two-player Games

    One-shotTwo-player GamesOne-shot Two-player Games

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    49/214

    One shot games

    Exercise 2

    One shot gamesMatchingTable functions

    Programming toolsThe scope operatorif  as function/as statement

    Exercise 2

    One-shotTwo-player GamesInteractive experiments

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    50/214

    One shot games

    Matching

    Table functions

    Programmingtools

    The scopeoperator

    if  as function/asstatement

    Exercise 2

    The subject’s payoff also depends on the decisions of other subjects.Example:  Prisoner’s dilemma

    cooperate defectcooperate   3,3 0,5

    defect   5,0 1,1

    Hint: use parameters  to make your program moreflexible.

    cooperate defectcooperate   r,r s,tdefect   t,s p,p

    One-shotTwo-player GamesPD – steps

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    51/214

    One shot games

    Matching

    Table functions

    Programmingtools

    The scopeoperator

    if  as function/asstatement

    Exercise 2

    1.   create pairs

    2.   set parameters:   r, t, s, p 

    3.   initialize variables: partner

    choice partnerchoice

    4.  subjects’ choice

    5.   profit calculation

    6.   results

    See prisoner dilemma.ztt

    One-shotTwo-player Games1. Create pairs - a simple matching

    d

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    52/214

    One shot games

    Matching

    Table functions

    Programmingtools

    The scopeoperator

    if  as function/asstatement

    Exercise 2

    procedure

    In the   Background set:  number of 

    subjects=10

      number of groups=5

    Then from the menuselect   Treatment   →Matching  →  Partner.

    To  check the matching, from the menu selectTreatment→  Parameter table.

    One-shotTwo-player Games2. and 3. Parameters and variables

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    53/214

    One shot games

    Matching

    Table functions

    Programmingtools

    The scopeoperator

    if  as function/asstatement

    Exercise 2

    Table functionsThe function   find()   is atable function, i.e. a func-tion which does not only

    refer to a single record of a table, but runs over thewhole table.

    A complete list of table functions can be found at page46 of the Reference Manual.

    One-shotTwo-player GamesFind the partner

    partner=find(same(Group)

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    54/214

    One shot games

    Matching

    Table functions

    Programmingtools

    The scopeoperator

    if  as function/asstatement

    Exercise 2

    partner=find(same(Group)

    &not(same(Subject)),Subject)

      find(condition, x) looks at all the records in atable, from top to bottom, and returns the value of variable  x of the first record in which condition isTRUE.

      same(x) is TRUE for all records in the table, wherethe variable (or expression)  x takes the same valueit has in the “reference record”.

      not(same(x)) is TRUE when  same(x) is FALSE

    and vice versa. One-shot

    Two-player Games4. 5. and 6. Choices and results

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    55/214

    One shot games

    Matching

    Table functions

    Programmingtools

    The scopeoperator

    if  as function/asstatement

    Exercise 2

    4.  subjects’ choice:

    with radiobuttons:!radio:0="D";1="C";

    5.   profit calculation:scope operator (:) and

    if as a function and asa statement. See page44 of the Referencemanual.

    6.   display results:layout!text:0="D";1="C";

    One-shotTwo-player GamesThe scope operator

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    56/214

    One shot games

    Matching

    Table functions

    Programmingtools

    The scopeoperator

    if  as function/asstatement

    Exercise 2

    see page 27 of the z-Tree Tutorial 

    partnerchoice=find(Subject==:partner, choice)

    The scope operator “:” indicates that the variablepartner  belongs to the record in which the cellpartnerchoice  lies, not to the record where   Subjectlies.

    One-shotTwo-player Gamesif  as function/as statement

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    57/214

    One shot games

    Matching

    Table functions

    Programmingtools

    The scopeoperator

    if  as function/asstatement

    Exercise 2

    if(condition a){c1}\\

    elsif(condition b1){c2}\\

    elsif(condition b2){c3}...\\else{c4}

    if  as a statement

      If condition  a  is TRUE, then command(s)  c1 is(are) executed;   if condition  a is FALSE and condition  b1  is TRUE,

    then command(s)  c2  is (are) executed; (etc.)   if conditions  a,  b1 and  b2 are FALSE, then

    command(s)  c4 is (are) executed;

    if  as a functionif(condition a, x, y)

    returns x if condition a is TRUE, returns y otherwise. One-shot

    Two-player GamesExercise 2: the Traveler’s dilemma

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    58/214

    One shot games

    Exercise 2The Traveler’s dilemma is a simple two-players game.

     each player can choose a number  between 2 and100

      the choice is simultaneous

      the player’s  profit is: equal to the number he chose, if this number is

    equal  to the number chosen by his partner equal to the number he chose +2, if this number

    is   lower  than the number chosen by his partner equal to the number he chose -2, if this number is

    higher  than the number chosen by his partner

    RepeatedTwo-player Games

    http://en.wikipedia.org/wiki/Traveler's_dilemmahttp://en.wikipedia.org/wiki/Traveler's_dilemma

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    59/214

    Repeatedsymmetric games

    Asymmetric games

    Programsexecution

    Exercise 3

    Part IV

    Repeated Two-player Games

    RepeatedTwo-player GamesRepeated Two-player Games

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    60/214

    Repeatedsymmetric games

    Asymmetric games

    Programsexecution

    Exercise 3

    Repeated symmetric gamesFinite horizon

    MatchingTable loadergrid box  and   container boxhistory box

    Indefinite horizon

    Matchingdo  statement and loopsChanging parameters across periods

    Asymmetric games

    The  Participate variablePrograms execution

    Exercise 3

    RepeatedTwo-player GamesSymmetric games with finite horizon

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    61/214

    Repeatedsymmetric games

    Finite horizon

    MatchingTable loader

    grid box andcontainer box

    history box

    Indefinite horizon

    Matching

    do   statement andloops

    Changingparameters acrossperiods

    Asymmetric games

    Programs

    execution

    Exercise 3

    Increase the number of periods:

      double-click onBackground

      set the number of periods and trialperiods

    See prisoner dilemma 2.ztt

    RepeatedTwo-player GamesMatching in repeated games - I

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    62/214

    Repeatedsymmetric games

    Finite horizon

    MatchingTable loader

    grid box andcontainer box

    history box

    Indefinite horizon

    Matching

    do   statement andloops

    Changingparameters acrossperiods

    Asymmetric games

    Programs

    execution

    Exercise 3

    When you have more than 1 group and multiple periods,there are several possible matching procedures.

    Option 1:  from the menu, choose  Treatment →Matching:

    partner  groups remain the same throughout the

    whole treatmentstranger  groups are randomly formed at the

    beginning of each period

    absolute stranger  players never meet more than once in

    the treatment (not always possible)

    To  check the matching, from the menu selectTreatment→  Parameter table.

    RepeatedTwo-player GamesMatching in repeated games - II

    Option 2: load the matching from an external table

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    63/214

    Repeatedsymmetric games

    Finite horizon

    MatchingTable loader

    grid box andcontainer box

    history box

    Indefinite horizon

    Matching

    do   statement andloops

    Changingparameters acrossperiods

    Asymmetric games

    Programs

    execution

    Exercise 3

    Option 2:  load the matching from an external table.

    1.  With MS Excel (or similar) create a tab-separated

    .txt file (“save as”→“other formats”).

    2.  Then, from z-tree, open the  Parameter Table3.   Select  Treatment→  Import Variable Table.

    4.   Set  Name of variable = Group.

    5.  Press OK and select the matching table (tabseparated .txt file).

    RepeatedTwo-player GamesMatching in repeated games - III

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    64/214

    Repeatedsymmetric games

    Finite horizon

    MatchingTable loader

    grid box andcontainer box

    history box

    Indefinite horizon

    Matching

    do   statement andloops

    Changingparameters acrossperiods

    Asymmetric games

    Programs

    execution

    Exercise 3

    If you double-click on one of the cells of the parametertable, you’ll see a program defining the  Group variable,for a specific subject in a given period.

    Programs in the parameter table are executed  after those in the background.

    RepeatedTwo-player Games

    R d

    Changing parameters across periods -1

    1 in z-Tree select the Background and choose

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    65/214

    Repeatedsymmetric games

    Finite horizon

    MatchingTable loader

    grid box andcontainer box

    history box

    Indefinite horizon

    Matching

    do   statement andloops

    Changingparameters acrossperiods

    Asymmetric games

    Programs

    execution

    Exercise 3

    1.   in z Tree, select the   Background and chooseTreatment→  New table.

    2.  create a new table (with Excel, or similar programs)

    3.  save the table as a  tab delimited   .txt file

    4.  the first column reports the name of the table you

    want to load Repeated

    Two-player Games

    R t d

    Changing parameters across periods - 2

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    66/214

    Repeatedsymmetric games

    Finite horizon

    MatchingTable loader

    grid box andcontainer box

    history box

    Indefinite horizon

    Matching

    do   statement andloops

    Changingparameters acrossperiods

    Asymmetric games

    Programs

    execution

    Exercise 3

    5.   in z-Tree, select the   Background and chooseTreatment→  New table loader.

    6.  Append/Replace filename: name of your .txt file

    7.   in the Background, afterthe  Table Loader create anew  Program, to load thenew parameters.

    RepeatedTwo-player Games

    Repeated

    Changing parameters across periods - 3

    An alternative possibility is setting parameters manually

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    67/214

    Repeatedsymmetric games

    Finite horizon

    MatchingTable loader

    grid box andcontainer box

    history box

    Indefinite horizon

    Matching

    do   statement andloops

    Changingparameters acrossperiods

    Asymmetric games

    Programs

    execution

    Exercise 3

    An alternative possibility is setting parameters manually,adding programs in the  Parameter Table.

    RepeatedTwo-player Games

    Repeated

    Grid boxes and Container boxes - I

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    68/214

    Repeatedsymmetric games

    Finite horizon

    MatchingTable loader

    grid box andcontainer box

    history box

    Indefinite horizon

    Matching

    do   statement andloops

    Changingparameters acrossperiods

    Asymmetric games

    Programs

    execution

    Exercise 3

    Now the payoff matrix of the game changes every period.

    You might want to show it on the subjects’ screens.

    RepeatedTwo-player Games

    Repeated

    Grid boxes and Container boxes - II

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    69/214

    Repeatedsymmetric games

    Finite horizon

    MatchingTable loader

    grid box andcontainer box

    history box

    Indefinite horizon

    Matching

    do   statement andloops

    Changingparameters acrossperiods

    Asymmetric games

    Programs

    execution

    Exercise 3

    A   container box   is abox that can contain otherboxes.

    Note: the   relative mea-sures   of the boxes it con-

    tains are defined   w.r.t. the container box , not to thewhole screen.

    A   grid box  presents itemsin a tabular form.

    RepeatedTwo-player Games

    Repeated

    History box - I

    To remind subjects about what happened in past

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    70/214

    Repeatedsymmetric games

    Finite horizon

    MatchingTable loader

    grid box andcontainer box

    history box

    Indefinite horizon

    Matching

    do   statement andloops

    Changingparameters acrossperiods

    Asymmetric games

    Programs

    execution

    Exercise 3

    To remind subjects about what happened in pastperiods, you can insert a  history box.

    RepeatedTwo-player Games

    Repeated

    History box - IIsee the Reference Manual, page 18.

    li t lt f

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    71/214

    psymmetric games

    Finite horizon

    MatchingTable loader

    grid box andcontainer box

    history box

    Indefinite horizon

    Matching

    do   statement andloops

    Changingparameters acrossperiods

    Asymmetric games

    Programs

    execution

    Exercise 3

      lists results fromprevious periods

     only takes variablesform the   subjectstable

     a label row contains

    the labels

      if the table is too long, a scroll-bar appears

     Option: showing/not showing the current period.

    RepeatedTwo-player Games

    Repeated

    Indefinite number of periods

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    72/214

    psymmetric games

    Finite horizon

    MatchingTable loader

    grid box andcontainer box

    history box

    Indefinite horizon

    Matching

    do   statement andloops

    Changingparameters acrossperiods

    Asymmetric games

    Programs

    execution

    Exercise 3

    1.  Define a treatment with a single period.

    2.   In the   Background, create a new program whichruns on the  globals table. In this program, youcan set the variable   RepeatTreatment, as follows:

    RepeatedTwo-player Games

    Repeated

    Random matching in programs - IHard to use the  parameter table or to import an

    t l t hi t bl

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    73/214

    symmetric games

    Finite horizon

    MatchingTable loader

    grid box andcontainer box

    history box

    Indefinite horizon

    Matching

    do   statement andloops

    Changingparameters acrossperiods

    Asymmetric games

    Programs

    execution

    Exercise 3

    external matching table.

    ⇒ Matching   in a program   in the   Background, runningon the  globals table (it runs only once, at thebeginning of each period).

     generate a different random number (rand) for each

    subject;  generate the variable rank, which sorts subjects

    according to the variable rand;

     group together subject having consecutive ranks.

    RepeatedTwo-player Games

    Repeated

    Random matching in programs - II

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    74/214

    symmetric games

    Finite horizon

    MatchingTable loader

    grid box andcontainer box

    history box

    Indefinite horizon

    Matching

    do   statement andloops

    Changingparameters acrossperiods

    Asymmetric games

    Programs

    execution

    Exercise 3

    //CREATE GROUPS

    i=1;

    repeat{i=i+1;

    subjects.do{

    rand=random();

    }

    subjects.do{rank=subjects.count(rand

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    75/214

    symmetric games

    Finite horizon

    MatchingTable loader

    grid box andcontainer box

    history box

    Indefinite horizon

    Matching

    do   statement andloops

    Changingparameters acrossperiods

    Asymmetric games

    Programs

    execution

    Exercise 3

    do  statement:see page 62 of the Tutorial 

    With  do{commands}  the commands are executed   for all records  in the current table.

    For example, with  subjects.do{commands}we specify that the commands should be executed for all

    records in the  subjects table.

    repeat{commands}   while (condition) statement

    The commands are executed.   Then   it is checked

    whether the condition is TRUE, and as long as it is thecommands are repeated.

    Loops can be left with the key combination Ctrl+Alt+F5

    RepeatedTwo-player Games

    Repeatedt i

    Different games in different periods IWhen you don’t know in advance the length of atreatment you can:

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    76/214

    symmetric games

    Finite horizon

    MatchingTable loader

    grid box andcontainer box

    history box

    Indefinite horizon

    Matching

    do   statement andloops

    Changingparameters acrossperiods

    Asymmetric games

    Programs

    execution

    Exercise 3

    treatment, you can:

    1.   randomize:

    //LOAD PARAMETERS FROM THE IMPORTED TABLE

    n=max(1,roundup(3*random(),1));

    //random number equal to 1, 2 or 3.r=payofftable.find(Period==\n, r);t=payofftable.find(Period==\n, t);p=payofftable.find(Period==\n, p);s=payofftable.find(Period==\n, s);

    RepeatedTwo-player Games

    Repeatedsymmetric games

    Different games in different periods II

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    77/214

    symmetric games

    Finite horizon

    Matching

    Table loader

    grid box andcontainer box

    history box

    Indefinite horizon

    Matching

    do   statement andloops

    Changingparameters acrossperiods

    Asymmetric games

    Programs

    execution

    Exercise 3

    2.   rotate:

    //LOAD PARAMETERS FROM THE IMPORTED TABLE

    n=if(mod(Period,3)==0,3,mod(Period,3));

    //number taking value 1, 2 or 3, in turn.

    r=payofftable.find(Period==   \n, r);...

    Note: setting parameters in the Parameter Table is lessflexible.

    RepeatedTwo-player Games

    Repeatedsymmetric games

    Games with asymmetric players - ISuppose now you want to let subjects play the prisonerdilemma sequentially

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    78/214

    symmetric games

    Asymmetric games

    The  Participatevariable

    Programsexecution

    Exercise 3

    dilemma  sequentially .

    2 types  of players: 1 (first mover) and 2 (secondmover)⇒  type  is a subject variable.

    If types remain fixed across periods, you can set them inthe  Parameter Table.

    RepeatedTwo-player Games

    Repeatedsymmetric games

    Games with asymmetric players - IIYou can also assign types with a  program   in theBackground  (on the  globals table).

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    79/214

    symmetric games

    Asymmetric games

    The  Participatevariable

    Programsexecution

    Exercise 3

    ( )

    numsubjects=subjects.maximum(Subject);

    subjects.do{type=if(Subject

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    80/214

    symmetric games

    Asymmetric games

    The  Participatevariable

    Programsexecution

    Exercise 3

    It is possible to set types randomly at the beginning of each period, with a program in the   Background.

    1.  rank subjects according to some random variable

    2.   set type=1 for the firsthalf of the subjects,type=2  for the others

    3.  form groups pickingthe first subject fromthe first half, and thesecond subject from

    the second half.

    RepeatedTwo-player Games

    Repeatedsymmetric games

    The Participate variable

    Once you have defined the types, you can modify the

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    81/214

    y g

    Asymmetric games

    The  Participatevariable

    Programsexecution

    Exercise 3

    structure of the program. The  Participate variable in

    the   subjects table determines whether a subjectsenters a stage or not.

     If this variable has value1 then the subjectsenters the stage, i.e., the

    corresponding   ActiveScreen  appears on thesubjects computerscreen.

     Programs in the stageare executed   for all subjects.

    See prisoner dilemma sequential.ztt

    RepeatedTwo-player Games

    Repeatedsymmetric games

    Program execution

    At the beginning of each period programs are executed

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    82/214

    y g

    Asymmetric games

    Programsexecution

    Exercise 3

    At the beginning of each period,  programs  are executed

    in the following  order:1.  Standard variables (Subject, Period, etc.) are set.

    2.   Programs in   Background, in the order they appearin the .ztt file

    3.  Programs in the  Parameter Table

    cells  Subject programs (in current period) in thesubjects table

    top row  Role program in subjects table

    first column  Period program in globals table

    4.  Programs of the first stage

    RepeatedTwo-player Games

    Repeatedsymmetric games

    Exercise - battle of the sexesThe “battle of the sexes” is a two-player asymmetricgame.

    http://en.wikipedia.org/wiki/Battle_of_the_sexes_(game_theory)http://en.wikipedia.org/wiki/Battle_of_the_sexes_(game_theory)

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    83/214

    Asymmetric games

    Programsexecution

    Exercise 3

    g

    Rob (row player) and Clara (column player) want to goout together tonight. She prefers the box, he is a fan of ballet.

    box balletbox   3,5 0,0ballet   0,0 5,3

    They will go out together every Tuesday, as long as theirengagement lasts.

    cooperate defectcooperate   m, hc l, ldefect   l, l hr, m

    RepeatedTwo-player Games

    Repeatedsymmetric games

    Exercise - details - I

    Indefinitely repeated game. There is a 10%

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    84/214

    Asymmetric games

    Programsexecution

    Exercise 3

      Indefinitely repeated  game. There is a 10%probability that Rob and Clara break up before nextTuesday.

      Partner matching  (couples remain the samethroughout the treatment). Types are also fixed

    across periods.   l  = 0,  m = 3, while  hc   and  hr   parameters vary

    randomly across periods: sometimes the box match is particularly

    important: hc=8, hr=5; sometimes the ballet company is very good:

    hc=5, hr=8; otherwise hc=5, hr=5;

    RepeatedTwo-player Games

    Repeatedsymmetric games

    Exercise - details - II

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    85/214

    Asymmetric games

    Programsexecution

    Exercise 3   Simultaneous moves.

      Show a  history box and two  grid boxes to

    display the payoff matrices.  You can use the file prisoner dilemma sequential.ztt

    as a starting point.

    RepeatedTwo-player Games

    Repeatedsymmetric games

    Exercise - screen-shot

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    86/214

    Asymmetric games

    Programsexecution

    Exercise 3

    RepeatedTwo-player Games

    Repeatedsymmetric games

    Exercise - hint

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    87/214

    Asymmetric games

    Programsexecution

    Exercise 3

    Create 3 stages:

    1.  Rob’s choice stage

    2.  Clara’s choice stage

    3.   Results

    To let the two players play simultaneously, set Rob’s

    choice stage and Clara’s choice stage to “start ifpossible”.

    Solution:  battle of sexes.ztt

    Multi-playerGames: Auctionsand Markets

    Second pricesealed-bid auctions

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    88/214

    sealed bid auctions

    Dutch Auctions

    Posted-offermarkets

    Double Auctions

    Part V

    Multi-player Games: Auctions

    and Markets

    Multi-playerGames: Auctionsand Markets

    Second pricesealed-bid auctions

    Multi-player Games: Auctions and Markets

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    89/214

    sealed bid auctions

    Dutch Auctions

    Posted-offermarkets

    Double Auctions

    Second price sealed-bid auctionscheckers

    while statementvariables into labels

    Dutch AuctionsThe  later statementPrograms into buttons

    Posted-offer markets

    the  contracts tablethe  contracts creation boxthe  contracts list box

    Double Auctions

    Multi-playerGames: Auctionsand Markets

    Second pricesealed-bid auctions

    Second price sealed-bid auctions - IPurpose: elicit the true value of a good (e.g. a mug)for each of the subjects.

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    90/214

    checkers

    while statement

    variables intolabels

    Dutch Auctions

    Posted-offermarkets

    Double Auctions

    for each of the subjects.

     each subject receives an initial endowment (20euros)

     each subject makes an offer for the mug (possiblyeven above 20 euros). The offers are secret and

    simultaneous.

     the subject who makes the highest bid wins themug and has to pay a price equal to the secondhighest bid.

      in case of a tie, the winner is drawn at randomamong the bidders who submitted the highest bid.

    See second price auction.ztt

    Multi-playerGames: Auctionsand Markets

    Second pricesealed-bid auctions

    Second price sealed-bid auctions - II

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    91/214

    checkers

    while statementvariables intolabels

    Dutch Auctions

    Posted-offermarkets

    Double Auctions

    Multi-playerGames: Auctionsand Markets

    Second pricesealed-bid auctions

    checkerscheckers  are used to  verify the validity of an input.

    To create a checker select the button you need to

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    92/214

    checkers

    while statementvariables intolabels

    Dutch Auctions

    Posted-offermarkets

    Double Auctions

    To create a checker, select the button you need to

    “check”, then, from the menu:Treatment→New checker

    Multi-playerGames: Auctionsand Markets

    Second pricesealed-bid auctions

    while  statement - I

    To sort the winner at random in case of a tie we use the

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    93/214

    checkers

    while statementvariables intolabels

    Dutch Auctions

    Posted-offermarkets

    Double Auctions

    To sort the winner at random in case of a tie, we use the

    while statement:

    while(subjects.count(winner==1)>1){

    subjects.do{

    rand=if(winner==1, random(), 0);}

    subjects.do{

    winner=if(rand==subjects.maximum(rand),1, 0);

    }

    }

    Multi-playerGames: Auctionsand Markets

    Second pricesealed-bid auctions

    while  statement - II

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    94/214

    checkers

    while statementvariables intolabels

    Dutch Auctions

    Posted-offermarkets

    Double Auctions

    The general use is:

    while(condition){

    program;

    }

    While the  condition is TRUE, the program is executed.

    Reminder: loops can be left with the key combination

    Ctrl+Alt+F5.

    Multi-playerGames: Auctionsand Markets

    Second pricesealed-bid auctions

    Variables into labels

    In the   Active screen of the  Results stage, we tell

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    95/214

    checkers

    while statementvariables intolabels

    Dutch Auctions

    Posted-offermarkets

    Double Auctions

    each participants whether he is the winner.

    In the input  label  we write:   You are the winner.

    This becomes:  “You are the winner”, if the variable  winner  is

    equal to 1

     “You are not the winner”, if the variable  winner is

    equal to 0

    Do not forget the    sign at the beginning.

    Multi-playerGames: Auctionsand Markets

    Second pricesealed-bid auctions

    Dutch Auctions - I

    A Dutch auction is an auction in which the auctioneer

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    96/214

    Dutch Auctions

    The  laterstatement

    Programs intobuttons

    Posted-offermarkets

    Double Auctions

    begins with a very high asking price, which isprogressively lowered until some participant accepts theauctioneer’s price, or until a predetermined time is over.

     all subject are buyers

      global variables: initial asking price duration of the auction (in seconds)  → duration step of decrease of the price  → step

    frequency of decrease of the price (in seconds)  →time interval

    See dutch auction.ztt

    Multi-playerGames: Auctions

    and Markets

    Second pricesealed-bid auctions

    Dutch Auctions - II

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    97/214

    Dutch Auctions

    The  laterstatement

    Programs intobuttons

    Posted-offermarkets

    Double Auctions

    Multi-playerGames: Auctions

    and Markets

    Second pricesealed-bid auctions

    The  later statementIn the   Auction stage, we run the following program:

    later(time interval) repeat{

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    98/214

    Dutch Auctions

    The  laterstatement

    Programs intobuttons

    Posted-offermarkets

    Double Auctions

    later(time_interval) repeat{

    price=price-step;duration=duration-time_interval;

    }

    The general form  is:

    later(a) repeat{

    program;

    }

    Expression  a is calculated. The resulting number of seconds later, the  program is executed.

    Note:  to exit the loop, set  a to a negative value.

    Multi-playerGames: Auctions

    and Markets

    Second pricesealed-bid auctions

    Programs into buttonsWhen a subject tries to buy the good:

     check that the good has not been sold so far

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    99/214

    Dutch Auctions

    The  laterstatement

    Programs intobuttons

    Posted-offermarkets

    Double Auctions

    g

     run a program to assign the good to the subject

    Multi-playerGames: Auctions

    and Markets

    Second pricesealed-bid auctions

    Posted offer markets - I

    subjects in the role of buyers and sellers

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    100/214

    Dutch Auctions

    Posted-offermarkets

    the  contractstable

    the  contractscreation box

    the  contracts

    list box

    Double Auctions

     subjects in the role of  buyers and sellers 

     each seller makes an offer, without knowing theoffers made by other buyers.

     buyers act  sequentially , in random order

     they can see all the sellers’ offers that are still open,and choose which one to accept, if any.

     accepted offers are not visible anymore to

    subsequent buyers.

    See posted offers markets.ztt

    Multi-playerGames: Auctions

    and Markets

    Second pricesealed-bid auctions

    Posted offer markets - II

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    101/214

    Dutch Auctions

    Posted-offermarkets

    the  contractstable

    the  contractscreation box

    the  contracts

    list box

    Double Auctions

    Multi-playerGames: Auctions

    and Markets

    Second pricesealed-bid auctions

    D h A i

    The  contracts table

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    102/214

    Dutch Auctions

    Posted-offermarkets

    the  contractstable

    the  contractscreation box

    the  contracts

    list box

    Double Auctions

    Multi-playerGames: Auctions

    and Markets

    Second pricesealed-bid auctions

    D t h A ti

    The  contracts creation box

    Records in the  Contracts table are created via inputsin the Contract Creation Box

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    103/214

    Dutch Auctions

    Posted-offermarkets

    the  contractstable

    the  contractscreation box

    the  contracts

    list box

    Double Auctions

    in the  Contract Creation Box.

    Multi-playerGames: Auctions

    and Markets

    Second pricesealed-bid auctions

    Dutch Auctions

    Buyers enter the Acceptance stage one byone

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    104/214

    Dutch Auctions

    Posted-offermarkets

    the  contractstable

    the  contractscreation box

    the  contracts

    list box

    Double Auctions

      the variable   Priority, if set, defines the orderaccording to which

    subjects enter the stage.

      if  Priority  is not set,subjects enter the stagein random order.

    Multi-playerGames: Auctions

    and Markets

    Second pricesealed-bid auctions

    Dutch Auctions

    The  contracts list box

    Available offers are displayed in a  Contract list box.

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    105/214

    Dutch Auctions

    Posted-offermarkets

    the  contractstable

    the  contractscreation box

    the  contracts

    list box

    Double Auctions

    Multi-player

    Games: Auctionsand Markets

    Second pricesealed-bid auctions

    Dutch Auctions

    Double auctions - I

    see the z-Tree Tutorial, pages: 57-66 

     subjects in the role of buyers and sellers.

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    106/214

    Dutch Auctions

    Posted-offermarkets

    Double Auctions

     both sellers and buyers  can make offers,  at the same time .

     each seller and each buyer can make  more than one 

    offer .

      sellers and buyers can see  all  the open offers (madeby buyers and by sellers)

     each seller can accept  only one  of the buyers’ offers.

     each buyer can accept  only one  of the sellers’ offers.

    See double auction.ztt

    Multi-player

    Games: Auctionsand Markets

    Second pricesealed-bid auctions

    Dutch Auctions

    Double auctions - II

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    107/214

    Dutch Auctions

    Posted-offermarkets

    Double Auctions

    Multi-player

    Games: Auctionsand Markets

    Second pricesealed-bid auctions

    Dutch Auctions

    Double auctions - screenshot

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    108/214

    Posted-offermarkets

    Double Auctions

    Multi-player

    Games: Auctionsand Markets

    Second pricesealed-bid auctions

    Dutch Auctions

    Double auctions - accepting an offer

    1.  set the ID of the

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    109/214

    Posted-offermarkets

    Double Auctions

    accepter2.  close all other offers

    by the same proposerand by the same

    accepter

    3.   if all subjects havesigned a contract,leave the stage

    Note: the variable   LeaveStage is preset in z-Tree.

    Advanced

    concepts,questionnaires and

    crashes

    Advanced concepts

    Summary of z-Tree

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    110/214

    tablesQuestionnaires

    Handling crashes

    Part VI

    Advanced concepts,

    questionnaires and crashes

    Advanced

    concepts,questionnaires and

    crashes

    Advanced concepts

    Summary of z-Tree

    Advanced concepts, questionnaires andcrashes

    Advanced concepts

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    111/214

    tables

    Questionnaires

    Handling crashes

    Arraysiterator

    Data from previous periodsBankruptcy rules

    ChatsString variables

    Summary of z-Tree tables

    Questionnaires

    Handling crashesCrash of a client PCCrash of the server PC

    Advanced

    concepts,questionnaires and

    crashes

    Advanced concepts

    Arrays

    ArraysArrays are   indexed variables . In an index set, every finite,equidistant subset of numbers is allowed (e.g  1,2,3,...;but also  5, 10, 15, ...).

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    112/214

    iterator

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Tree

    tables

    Questionnaires

    Handling crashes

    , , , )

    The index set needs to be defined  before  the first use of the array.This is done with one of the following instructions:

      array arrayname[] → defines an array withindices from 1 to the number of subjects

      array arrayname[n] → defines an array withindices from 1 to n

      array arrayname[x,y] → defines an array withindices from x to y

      array arrayname[x,y,z] → defines an arraywith indices x, x+z, x+2z,..., y.

    Advanced

    concepts,questionnaires and

    crashes

    Advanced concepts

    Arrays

    i

    Arrays - an example

    //the index set of array p is 10, 15, 20

    array p[10, 20, 5];

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    113/214

    iterator

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Tree

    tables

    Questionnaires

    Handling crashes

    p[10]=1;

    p[15]=5;

    p[20]=2;

    p[30]=3;   //sets p[20] to 3

    x = p[10] + p[20]; // x=4

    arrayname[indexvalue]  reports the element of arrayarrayname, corresponding to the index   indexvalue.

    Note: the expression   indexvalue   is rounded to thenearest possible index.

    Advanced

    concepts,questionnaires and

    crashes

    Advanced concepts

    Arrays

    it t

    iterator

    Loops can be programmed with the statements  repeat

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    114/214

    iterator

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Tree

    tables

    Questionnaires

    Handling crashes

    and  while.

    Another way of programming loops is by usingiterators.

    An iterator creates a  small temporary table  that containsonly one variable.

    When a table function or a do-statement is applied to an

    iterator, it corresponds to a   loop over the valuescontained in the table.

    Advanced

    concepts,questionnaires and

    crashes

    Advanced concepts

    Arrays

    iterator

    iterator  - exampleThis example provides two possible ways of calculatingthe sum of the square of the first five natural numbers:

    SquareSum= 1 + 4 + 9 + 16 + 25 = 55

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    115/214

    iterator

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Tree

    tables

    Questionnaires

    Handling crashes

    First way:SquareSum = iterator(i, 1, 5).sum(power(i,2));

    Second way:

    SquareSum = 0;

    iterator(i,5).do{

    :SquareSum = :SquareSum + power(i,2);

    }

    Note the use of the  scope operator  to refer to avariable that is in the table  which contains  the table onwhich the program is running.

    Advanced

    concepts,questionnaires and

    crashes

    Advanced concepts

    Arrays

    iterator

    iterator: syntax

    An iterator has the following  syntax:

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    116/214

    iterator

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Tree

    tables

    Questionnaires

    Handling crashes

      iterator (varname) → variable  varname runsfrom 1 to the number of subjects.

      iterator (varname, n) → variable  varnameruns from 1 to n.

      iterator (varname, x, y) → variable  varnameruns from x to y.

      iterator (varname, x, y, z) → variablevarname runs from x to y with steps of z.

    Advanced

    concepts,questionnaires and

    crashes

    Advanced concepts

    Arrays

    iterator

    Retrieving data from previous periodsIn z-Tree, the subjects database is set up freshly in everyperiod, so the information about earlier periods is notavailable directly.

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    117/214

    iterator

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Tree

    tables

    Questionnaires

    Handling crashes

    However, the tables of the previous periods can beaccessed with the prefix OLD.

    So, if you want to copy some   variable from theprevious period, you can write:

    if (Period >1) {

    variable=OLDsubjects.find(same(subject),variable);

    }

    This way, you can only access data from the previousperiod. To access data from earlier periods, a differentprocedure should be followed.

    Advanced

    concepts,questionnaires and

    crashes

    Advanced concepts

    Arrays

    iterator

    Data from previous periods - example

    Suppose you want to run an experiment with thefollowing structure:

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    118/214

    iterator

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Tree

    tables

    Questionnaires

    Handling crashes

    1.   N periods

    2.  in every period, each subject earns a certain amountof points

    3.  the subject’s profit is determined at the end of 

    period N: three of the periods are drawn at random by the

    subject the profit is set equal to the sum of the points

    earned by the subject in these three periods

    Example: values from previous periods.ztt

    Advanced

    concepts,questionnaires and

    crashes

    Advanced concepts

    Arrays

    iterator

    Data from previous periods - I

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    119/214

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Tree

    tables

    Questionnaires

    Handling crashes

    Advanced

    concepts,questionnaires and

    crashes

    Advanced concepts

    Arrays

    iterator

    Data from previous periods - IITo retrieve data from all earlier periods, these data haveto be stored in a  user-defined table  with   lifetime setto  Treatment or to  Session.

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    120/214

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Tree

    tables

    Questionnaires

    Handling crashes

    From the menu, select  Treatment→New table

    Advanced

    concepts,questionnaires and

    crashes

    Advanced concepts

    Arrays

    iterator

    Data from previous periods - III

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    121/214

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Tree

    tables

    Questionnaires

    Handling crashes

    Note:  again, here we use the   scope operator to referto variables in the   subjects table from the  pointstable

    Advanced

    concepts,questionnaires and

    crashes

    Advanced concepts

    Arrays

    iterator

    Data from previous periods - IV

    1.  store points form the

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    122/214

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Tree

    tables

    Questionnaires

    Handling crashes

    last period

    2.  draw a random periodNB. this box is shownonly if the draw is yet

    to be done.Display

    condition:

    selected[1]==0

    3.  calculate the profit, using the iterator.

    Advanced

    concepts,questionnaires and

    crashes

    Advanced concepts

    Arrays

    iterator

    Bankruptcy - I

    Tip: try to design the experiment in order to avoid

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    123/214

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Tree

    tables

    Questionnaires

    Handling crashes

    possible losses.If losses occur, can be covered by the following sources:

     profits from previous periods and treatments

      show-up fee

     money injected by the experimenter during thesession

    Example: bankruptcy.ztt

    Advanced

    concepts,questionnaires and

    crashes

    Advanced concepts

    Arrays

    iterator

    Bankruptcy - II

    If previous profits are not enough to cover all losses, butthe  show-up fee  is, a message appears on the subject’s

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    124/214

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Tree

    tablesQuestionnaires

    Handling crashes

    screen.This message informs the subject that he can chooseeither to use the show-up fee, or to drop out of the 

    experiment .

      if the subject chooses to use the show-up fee, hemay simply play on.

     otherwise, the subject reaches the stateBankruptShowupNo  (which you can read in the

    clients table), and the experimenter has to releasehim manually from the server.

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    125/214

    Advanced

    concepts,questionnaires and

    crashes

    Advanced concepts

    Arrays

    iterator

    Bankruptcy - IV

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    126/214

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Tree

    tablesQuestionnaires

    Handling crashes

    Advanced

    concepts,questionnaires andcrashes

    Advanced concepts

    Arrays

    iterator

    D f

    Bankruptcy - V

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    127/214

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Tree

    tablesQuestionnaires

    Handling crashes

    Advanced

    concepts,questionnaires andcrashes

    Advanced concepts

    Arrays

    iterator

    D t f

    Chats

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    128/214

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Tree

    tablesQuestionnaires

    Handling crashes

    Example: chat.ztt

    Advanced

    concepts,questionnaires andcrashes

    Advanced concepts

    Arrays

    iterator

    Data from

    Chat Box

    In a stage, you can add a chat box by clicking on:Treatment  →  New Box   →  New Chat Box

    1 if th t bl h t t t th h t

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    129/214

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Tree

    tablesQuestionnaires

    Handling crashes

    1.  specify the table where you want to store the chatdata contracts table user-defined table

    2.  specify what recordsyou want to displayon the subject’sscreen

    3.   specify the output

    text

    Advanced

    concepts,questionnaires andcrashes

    Advanced concepts

    Arrays

    iterator

    Data from

    Chat data

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    130/214

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Treetables

    Questionnaires

    Handling crashes

     messages are saved in the  contracts table, or in

    the user-defined table specified in the Chat-boxdialogue.

      The  contracts table and the user-defined tableswere the  only tables   in which text-variables could

    be saved, until version 3.4.   To  display  text variables on the screen, write ”-1”

    in the layout filed.

    Advanced

    concepts,questionnaires andcrashes

    Advanced concepts

    Arrays

    iterator

    Data from

    String variablesFrom z-Tree version 3.4 it is possible to enter text intoinput variables, using the layout  !string.

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    131/214

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Treetables

    Questionnaires

    Handling crashes

    In  output items, the expression in Layout should be aninteger number, and determines how many characterswill be reserved for the string output.Example: string variables.ztt

    Advanced

    concepts,questionnaires andcrashes

    Advanced concepts

    Arrays

    iterator

    Data from

    String functions   mid(str, n1, n2) extracts  n2   characters from

    string  str , starting from character  n1.   pos(srt1, str2, n) returns the position of  str2 

    in str1 starting the counting process at number n

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    132/214

    Data fromprevious periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Treetables

    Questionnaires

    Handling crashes

    in  str1, starting the counting process at number  n.   len(str) returns the number of characters of 

    string  str .   upper(str) returns string  str   in capitals.

      lower(str) returns string str 

      in lower cases.   trim(str) removes leading and trailing spacesfrom  str .

      format(n1,n2) returns  n1  as a string variable,rounded to the precision of  n2 .

      if(a,str1,str2) returns  str1   if  a  is true,otherwise  str2 .

     relational operators can be applied to pairs of stingexpressions

    Advanced

    concepts,questionnaires andcrashes

    Advanced concepts

    Arrays

    iterator

    Data from

    Example

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    133/214

    previous periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Treetables

    Questionnaires

    Handling crashes

    Advanced

    concepts,questionnaires andcrashes

    Advanced concepts

    Arrays

    iterator

    Data from

    Example

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    134/214

    previous periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Treetables

    Questionnaires

    Handling crashes

    Advanced

    concepts,questionnaires andcrashes

    Advanced concepts

    Arrays

    iterator

    Data from

    Example

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    135/214

    previous periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Treetables

    Questionnaires

    Handling crashes

    Advanced

    concepts,questionnaires andcrashes

    Advanced concepts

    Arrays

    iterator

    Data from

    Example

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    136/214

    previous periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Treetables

    Questionnaires

    Handling crashes

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    137/214

    Advanced

    concepts,questionnaires andcrashes

    Advanced concepts

    Arrays

    iterator

    Data fromi i d

    Example

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    138/214

    previous periods

    Bankruptcy rules

    Chats

    String variables

    Summary of z-Treetables

    Questionnaires

    Handling crashes

    Advanced

    concepts,questionnaires andcrashes

    Advanced concepts

    Summary of z-Treetables

    Questionnaires

    The  subjects tableContains  one record per subject . It is freshly set up foreach period. The subjects table of the previous period isavailable under the name  OLDsubjects.

    I h h f ll i i bl

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    139/214

    Handling crashesIn the   subjects table, the following variables arealways defined by z-Tree:

      Period

      Subject   Group

      Profit

     TotalProfit - this is calculated automatically. It

    should not be changed manually.   Participate

      LeaveStage

    Advancedconcepts,

    questionnaires andcrashes

    Advanced concepts

    Summary of z-Treetables

    Questionnaires

    The  globals table

    This table contains  a single record , i.e. a single line. It

    stores values that are the same for all subjects. It isfreshly set up for each period The globals table of

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    140/214

    Handling crashes

    sto es a ues t at a e t e sa e o a subjects t sfreshly set up for each period. The   globals table of the previous period is available under the nameOLDglobals.

    In the   globals table, the following variables arealways defined by z-Tree:

      Period

      NumPeriods

      RepeatTreatment

    Advancedconcepts,

    questionnaires andcrashes

    Advanced concepts

    Summary of z-Treetables

    Questionnaires

    The  summary and  contracts tablesThe   summary table

    This table contains  one record per period . It is notdestroyed at the end of each period, as the   subjects

    and  globals table, but at the end of each treatment.

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    141/214

    Handling crashes

    g ,This table is most useful for observing aggregate data of the treatment.

    In the   summary table, the only variable defined by

    z-Tree is the variable Period.

    The  contracts table

    This table is used mainly for market experiments and

    chats. New records can be added to this table, andexisting records can be changed.

    In the  contracts table, the only variable defined byz-Tree is the variable Period.

    Advancedconcepts,

    questionnaires andcrashes

    Advanced concepts

    Summary of z-Treetables

    Questionnaires

    The  session tableThis table contains  one record per subject . This table isnever destroyed during a session, as it stores theaggregate profits earned by subjects in earlier treatments.

    It can also be used to  exchange information across t t t f t t t t ti i

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    142/214

    Handling crashes

    gtreatments , or from treatments to questionnaires .

    In the   subjects table, the following variables arealways defined and automatically calculated by z-Tree:

      Subject   Final Profit

      ShowUpFee

      ShowUpFeeInvested

      MoneyAdded

      MoneyToPay

      MoneyEarned

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    143/214

    Advancedconcepts,

    questionnaires andcrashes

    Advanced concepts

    Summary of z-Treetables

    Questionnaires

    Question forms(s)  contain several questions with different possible

    layouts.  answers in questionnaires are of no consequences

    ⇒ no earnings can be made in questionnaires. answers are saved as text and cannot be used in

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    144/214

    Handling crashes

    g q  answers are saved as text and cannot be used in

    programs.  the last question form of a questionnaire remains on

    the users’ screen until you continue (with a newtreatment, a new questionnaire, or simply shuttingdown z-leaf).

     Therefore, the final question form  cannot contain abutton.

    Advancedconcepts,

    questionnaires andcrashes

    Advanced concepts

    Summary of z-Treetables

    Questionnaires

    Layout of the questions

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    145/214

    Handling crashes

    Advancedconcepts,

    questionnaires andcrashes

    Advanced concepts

    Summary of z-Treetables

    Questionnaires

    Buttons, rulers, and variables1.  buttons: maximum one

    per question form.⇒ clicking a button

    closes the question form,if ibl

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    146/214

    Handling crashesif possible

    2.   rulers: are used to setthe regions where labels

    and questions arepositioned.

    3.   In questionnaires, only variables from the sessiontable can be retrieved. If you need to retrieve a

    specific variable from a treatment, you have to storeit in the session table with a command in thetreatment program (.ztt).

    Advancedconcepts,

    questionnaires andcrashes

    Advanced concepts

    Summary of z-Treetables

    Questionnaires

    Crash of a client PC - I

    When a subject’s PC disconnects from the server, the

    clients appears in parentheses in the clients table.

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    147/214

    Handling crashes

    Crash of a clientPC

    Crash of theserver PC

    First solution:Try to close  the Leaf program on the subject’s PC, and

    to  restart  it.

    Advancedconcepts,

    questionnaires andcrashes

    Advanced concepts

    Summary of z-Treetables

    Questionnaires

    Crash of a client PC - IIIf the first solution does not work, you can try to  movethe subject to a different computer.

    1.  Start a new PC and launch z-Leaf from there.2 From the client table drag the name of the new

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    148/214

    Handling crashes

    Crash of a clientPC

    Crash of theserver PC

    2.  From the client table,  drag the name of the newclient on the name of the client that does notwork. This will release the old client, and replacethe old with the new client.

    Advancedconcepts,

    questionnaires andcrashes

    Advanced concepts

    Summary of z-Treetables

    Questionnaires

    H dli h

    Crash of the server PC - I

    After a  crash of z-Tree, you have to follow thisprocedure carefully:

      restart z-tree

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    149/214

    Handling crashes

    Crash of a clientPC

    Crash of theserver PC

     open the client’s table

     restart all clients with the menu  Run →  Restartall clients.

     If no clients connect you have different options try to restart the clients manually wait (up to 4 minutes) and try again shut down and restart the experimenter’s PC, then

    follow the previous steps start z-Tree on a different computer

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    150/214

    Advancedconcepts,

    questionnaires andcrashes

    Advanced concepts

    Summary of z-Treetables

    Questionnaires

    Handling crashes

    Crash of the server PC - IIIWhen you manage to restart all the clients,

      select  Run →  Restore Client Order (2).

      then  Run →  Reload Database (3).

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    151/214

    Handling crashes

    Crash of a clientPC

    Crash of theserver PC

    Advancedconcepts,

    questionnaires andcrashes

    Advanced concepts

    Summary of z-Treetables

    Questionnaires

    Handling crashes

    Crash of the server PC - IV

      check  how many periods have been played(e.g., from the subjects table)

  • 8/17/2019 Z-Tree Lecture_notes_handout.pdf

    152/214

    Handling crashes

    Crash of a clientPC

    Crash of theserver PC

    ( )

     open the treatment that was running when thecrash took place, and  set the number of practice

    periods to -n  (where n is the nu