+ All Categories
Home > Documents > Short Introduction to z-Tree · Not all subjects may show up; if you need a speci c numbers make...

Short Introduction to z-Tree · Not all subjects may show up; if you need a speci c numbers make...

Date post: 18-Jan-2020
Category:
Upload: others
View: 2 times
Download: 0 times
Share this document with a friend
42
Short Introduction to z-Tree Paul Gortner
Transcript

Short Introduction to z-Tree

Paul Gortner

Table of Contents

Introduction

A Public Good Game

Multiple Boxes, Functions and Tables

Matching

Text Formating

z-Tree Output

General Advice

An Ultimatum Game

Conducting a computerized experiment (1/3)

You can conduct experiments in the FLEX (Frankfurter Labor furExperimentelle Wirtschaftsforschung).

Invite people for the experiment using Online Recruitment System forEconomic Experiments (ORSEE).

Not all subjects may show up; if you need a specific numbers makesure to invite some extra subjects.

Test program exhaustively before going to the lab.

Make a cheat sheet with all relevant steps.

Conducting a computerized experiment (2/3)

Upon subjects arriving:

1. Check subjects on list.

2. Send excess subjects home.

3. Randomly allocate seats to subjects or roles to subjects.

Distribute and read out instructions loud.

Frequently ask whether there are any questions.

Control questions:

1. Pen and Paper - allows explain the experiment in person.

2. Computerized - gather response to question as control variable.

Training rounds.

Conducting a computerized experiment (3/3)

Run treatment. Check for crashes, subjects with problems.

Elicit additional control variables (demographics, risk aversion).

Pay subjects individually, have them sign receipt.

Clean the lab.

General Features of z-Tree

Zurich Toolbox for Ready made Economic Experiments.

Programming language for economic experiments.

Automats network traffic and data collection.

Easy to put data in analyzable format.

Structure makes it lacking in flexibility.

Problems with Windows 8, Linux and Mac.

Literature

Urs Fischbacher: z-Tree Manual

Urs Fischbacher: z-Tree Reference Manual

Stefan Palan: Introduction to z-Tree

Maria Bigoni: z-Tree Crash Course

Description

Groups of 5 subjects.

Subjects decide which fraction of their initial endowment tocontribute to the public good.

Contributions to the public good are summed over subjects andmultiplied with the efficiency factor of 1.8.

Each subject gets what he retained of his initial allocation in additionto an even share of the public good.

The game is repeated for 10 rounds.

Subjects are paid their accumulated earnings.

New Treatment

Start with an new treatment

Number of Subjects and Periods

Double-clicking on Background lets you set general parameters

Define Background Variables

Custom variables are defined in the background.

Variables are defined in programs open dialog with Treatment −− >New Program, Crtl + Alt + P.

StagesTo get a graphical interface subjects can interact with, we need todefine a stage.

Access Treatment −− > New Stage, or Ctrl + Alt + S.

In this stage subjects will enter their contribution to the public good.

Boxes and Buttons

There different kind of boxes to present input or output in z-Tree.

For the contribution we use a standard box.

Treatment −− > New Box −− > Standard Box, or Ctrl + Alt + D.

ItemsOnce we have created a box we can fill it with items.

Treatment −− > New Item, or Crtl + Alt + I.

Items can contain input, or output variables, or just plain text.

Here we need an input field for the subject’s contribution.

ButtonsNow subjects can input a number.

For them to confirm it and move to the next stage, use a button.

Treatment −− > New Button, or Crtl + Alt + B.

Payoff CalculationIn a last stage, subjects get information about their payoff.

To display we use a history box. This is just one of many choices.

A history box allows to easily present information from past periods.

The variables are calculated with a program.

How it looks like: Stage 1

How it looks like: Stage 2

Multiple Boxes

In both previous screens, there was only one box.

If multiple boxes are included they have to be arranged properly.

Use width, height and distance to edges to adjust and place boxes onscreen.

Functions

I abs(x) - absolute value of x.

I and([condition 1],[condition 2]) - TRUE if a and b are true.Similar or([condition 1],[condition 2]), not[condition].

I if([condition], x, y) - takes value x if condition is met, y else.

I max(x,y) - Maximum of x and y. Similar min(x,y).

I mod(x,y) - Remainder after x is divided by y.

I random() - Random variable uniformly in [0, 1].

I randomgauss() - Random variable, standard normal.

I randompoisson(x) - Poisson distributed with average x.

I round(x,y) - Rounds x down to a multiple of y. Similarroundup(x,y) and rounddown(x,y).

I log(x), ln(x), atan(x), sin(x), sqrt(x), exp(x).

Tables (1/2)

Variables are stored in tables. There are predefined tables in thebackground. New tables can be created at will.

The most important tables are globals and subjects.

Programs are table specific, i.e. access variables stored in a specifictable.

Tables (2/2)

The subjects table has six predefined variables Period, Subject, Profit,TotalProfit, Participate. (Reference Manual p. 54).

In addition it contains user-defined variables.

This is how the table looks like during a session.

Predefined variables in globals are Period, NumPeriods,RepeatTreatment.

Table Functions

Table functions can be pre-ambled by table names, e.g.subjects.sum(x).

I find([condition],x) - first value of x where a is satisfied.

I maximum([condition], x) - maximum of values x.

I count([condition]) - Number of records meeting the condition.

I sum([condition], x) - Sum of the found values.

I average([condition], x) - Average of values.

I stddev([condition], x) - Standard devation of values.

I median([condition],x ) - median of values x.

I minimum([condition],x) - minimum of values x.

Access tables from last period with prefix OLD, i.e.OLD.subjects.find([condition],x).

Programs, Tables and Scope OperatorPrograms can call variables from other tables.

One way of doing that is to explicitly call a table.

A second way is the scope operator. The table hierachy is:I globals

I subjectI contracts

The scope operator references one table up.

Matching

So far Public Good Game with only 5 subjects.

However 24 places in the FLEX.

We can run the game with 4 groups. Hence subjects will have to bematched.

3 different matching protocols:

I fixed or partner

I stranger

I random

Matching: Stranger and Fixed

There are build in routines for matching.

Set number of groups in the background, i.e. 4 for 20 subjects.

Treatment −− > Matching −− > Stranger andTreatment −− > Matching −− > Partner for fixed matching.

Treatment −− > Parameter gives overview.

Matching: Random

No canned routine for random rematching.

Draw random variable for each subject at the beginning of eachperiod.

Rank subjects according to random draw.

Use the modulo function to group subjects.

Matching: Random (Code)

Formatting Text (1/3)Text can be formatted using rtf.

A simple example:

I qc - centering

I b - boldface

I fs20 - font size 20

For more commands, check the Reference Manual p.57f.

Formatting Text (2/3)

This can used to display variables:

The format of the output is unchanged. We can change that in layoutof the item.

Formatting Text (3/3)

We can also include variables in text.

In principle one can produce the rtf-code using office.

Save a document as rtf, open it with notepad copy paste in z-Tree.

z-Tree Output

z-tree writes an xls. file with all available information.

The xls. file is saved in format yy/mm/dd hhmm.

Save tables separately with Tools −− > separate tables.

Using German programs beware of interpretation of the decimal point!

z-Tree Output and Statistical Software

There are tools to make importing z-Tree output into statisticalsoftware easier.

z-Tree output can be imported to Stata with this tool: ztree2Stata.

To import data into R use: zTreeTables.

Programming Advice

Copy the code from a program into your favorite text editor toperform search, replace.

In case you are using Notepad++ Stefan Palan has a definition file tohighlight z-Tree code (link).

Define all variables in the background.

Program all treatments in one file. Use a variable to select treatment.

Comment code using // at the beginning of a line.

Testing an Debugging

Make sure to test the program exhaustively before running it in thelab.

Open multiple instances of z-Leaf and run the program as if in the lab.

To make this easier use the program openzleafs by Ernesto Reuben.

In case there is a logical error in a programs z-Tree will refer you tothe line in question.

If the error is on another level look at the xls. file z-Tree writes beforetesting.

An Ultimatum Game

A proposer is endowed with 10 Euros.

He can decide how much of that endowment to offer to a receiver.

The receiver can accept or reject the offer.

In case of acceptance the allocations implied by the offer are realized.

In case of rejection both get 0.

Matching and Roles

Subjects need to matched into pairs and assigned roles (receiver orproposer).

We want a flexible code that works for every even number of subjects.

Proposer’s Offer

Make a stage that only the proposer enters.

Use the Participate variable. Subjects participate if the variable is 1.

Apart from that we only need a box, where the Proposer can enter hisinput.

C.f. Public Good Game.

Receiver’s Decision (1/2)

The receiver can either accept or reject the proposer’s offer.

The Proposer’s offer is retrieved with the find function.

Receiver’s Decision (2/2)

For the receiver’s binary input radio-buttons are appropriate.

Payoffs (1/2)

Payoffs (2/2)


Recommended