by Urs Fischbacher



  z-Tree: Tips & Tricks


Licencing   Installation   First Steps   Programming   Layout   Running a session   Printing   Other Tips   Future improvements


Other Tips

top of page

I am interested in letting the subjects experiment with different contracts and displaying potential profits (for different effort levels of the agent), before they commit to a specific choice. Do you have recommendation on the best way to display large amounts of data?

You could program some kind of Profit Calculator. The players enter all decisions and get the resulting payoffs to know. Of course, one should only display the own calculations. This is no problem. You just make a Contract Creation box where the data can be entered. In the program, you add:

	Owner = : Subject;

And then you have a Contract List box where you show the contracts with:

	Owner == :Subject.

top of page

In a 10 period treatment, the subjects’ profits of the previous periods are to be paid their interests and displayed to the subjects. Using the OLD.tabel results in errors for the periods greater than 2. So how do I do this?

You should define the variable Profit only in the last period and define an own variable comparable to TotalProfit:

	TotalProfitWithInterest = 0;

	TotalProfitWithInterest = if( Period = 1, Profit0 , OLDsubjects.find( same( Subject ), 
	TotalProfitWithInterest ) *(1+Interestrate/100) +Profit0 );

The Profit you define as:

	Profit =0;
	if (Period == NumPeriods) {
		Profit = TotalProfitWithInterest ;
	}

top of page

In a treatment, the subjects are allowed to define values up to two positions after decimal point. I control whether the subjects calculate correctly using a checker. Unfortunately, the control does not work: Only “halfs” and “quarters” work (e.g. 2,75 or 0,5), but not numbers as 1.23 and 66.77 or 0.45 and 67.55. Why this?

The numbers are represented in binary system. Therefore only powers of 1/2 have a precise representation. Therefore, the equality operator in the checker is too precise. Just allow more tolerance for the checkers, e.g. define:

	abs( Input – TrueValue) <.005

Then the checker should work fine.

top of page

In my experiment, I need the program to choose a random number based on a binomial distribution. Subjects input an integer between 0 and 100 and after that, the program chooses an answer, negotiates or exits - based on a binomial distribution, where the probability of negotiation is the integer the subjects have chosen. I saw on the manuals that you can use the normal and Poisson distribution, but what about binomial?

You could do the following:

	p= 0.2;
	n= 100;
	i=0;
	s=0;
	while ( i<=100) {
		if random() < p) {
		s=s+1;
	}
	i=i+1;
	} // s is binomially distributed with n draws of probability p.

It is perhaps not the quickest way but it works.

top of page

Can the subjects be allowed to make losses during an experiment without being prompted to continue or quit?

Yes, this can be determined in the bankruptcy rules in the background of a treatment. Just delete the corresponding question and one of the answers. The non-empty answer is then automatically used.

top of page

Observer Subject

You can define a subject who sees the results of the experiment.  For this you define a variable Observer which you set to 0.  In all stages we add in a program in the subjects table the line

	Participate = if( Observer==0,1,0);

Next we define an additional stage in which the variables that are of interest here are shown on the active as well as on the waiting screen.  In the program using table functions, you have to omit the observer, i.e., you write lines such as the following:

	AvOffer = average(Observer ==0, Offer);

Now we define a subject with

	Observer =1;

With this an interested party may follow these variables at a PC different from the experimenter PC.

top of page

Checking of Exercises

You can leave the checking of exercises to the computer.  To this end you define a treatment that only contains the exercises.  Checkers check whether the values are correct.  Common errors can be caught by specialized checkers.  These must stand at the beginning.

Example:

	 Add 3 and -4
	 Checker: result != 7 / Note that the numbers are not both positive.
	 Checker: result == -1 / There is an error in your calculation.

The check questions for the first treatment are attached to the welcome treatment so that the subjects need not wait until all have clicked "continue" on the welcome screen to begin answering the check questions.

top of page

Dutch Auction

In the Dutch auction a price clock that gradually runs backwards is shown.  As soon as a buyer says stop, he or she receives the goods at the price displayed at that moment. In version 2.0 of z-Tree, you can program auctioneers: see in the appendix to the manual 3. The Dutch auction and postponed program execution.

top of page


Last modified: August 16, 2006; Urs Fischbacher (fiba@iew.unizh.ch), Marianne Sulzer