實驗經(jīng)濟學(xué)軟件ztree教程課件_第1頁
實驗經(jīng)濟學(xué)軟件ztree教程課件_第2頁
實驗經(jīng)濟學(xué)軟件ztree教程課件_第3頁
實驗經(jīng)濟學(xué)軟件ztree教程課件_第4頁
實驗經(jīng)濟學(xué)軟件ztree教程課件_第5頁
已閱讀5頁,還剩111頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、zTree Workshop: Fundamentals of zTreeJustin EsareyFlorida State UniversityDepartment of Political ScienceJuly 11th, 2005What is zTree?lZurich Toolbox for Readymade Economic ExperimentslConsists of two programslzTree (the programming environment and experiment server)lzLeaf (the client program for su

2、bjects)lDesigned primarily for public goods games, structured bargaining experiments, posted-offer-markets and double auctionsWhat You Will Need to Program in zTreelzTree and zLeaf Programs (zTree.exe and zLeaf.exe)lAvailable at /faculty/Sunder/ExperimentalEconomics/ExpEcon.htm

3、llzTree Tutorial Manual (ztree21tutorial.pdf)lA “guided tour” of zTrees capabilities; more instructionallzTree Reference Manual (ztree21ref.pdf)lAn organized reference of zTree codeReadings to DolTodaylBasic Experiments and Questionnaires (Tutorial pp. 7-16, 77-81)lTomorrowlRunning Experiments and R

4、ecovering Data (Tutorial pp. 83-89)lFunctions and Control Structures (Tutorial pp. 17-41)Programming A Simple Public Goods GamelRecall the idea of a Public Goods Game:lSome group of people, size N, receive an endowment of moneylEvery person chooses some proportion of their endowment to contributelTo

5、tal contributions are multiplied by X 1, then everyone receives that amount backlTotal payoff = (Endowment Contribution) + (X * Total Contributions) / NOpening zTree Es ist nicht englisch! Changing the language setting will not affect currently open treatments. You need to open a new treatment to ha

6、ve the defaults set to English.You must change the language setting every time you open zTree, even if your program was written under the “English” setting, because otherwise server messages will display in German when you run the program.Setting Language by DefaultStages of a Simple Public Goods Ga

7、melSubjects are broken into groups of NlSubjects receive their endowmentlSubjects make a choice for contributionlCalculate the size of the total public contribution and multiply by XlReport earnings (endowment kept + share of the public good) to all subjectsl(Repeat?)TerminologylStage: In an experim

8、ent, one screen display on which a subject can take one or a few actionslTreatment: A related series of stages through which subjects pass; can be repeatinglSession: A series of treatments all performed on the same subjects in sequenceStages of a Simple Public Goods GamelSubjects are broken into gro

9、ups of NlSubjects receive their endowmentlSubjects make a choice for contributionlCalculate the size of the total public contribution and multiply by XlReport earnings (endowment kept + share of the public good) to all subjectsBackground StageStage 1Stage 2More TerminologylProgram: A set of procedur

10、es used to assign variables, calculate payoffs, store information, etc.lActive Screen: The screen on which subjects see information and make decisionslWaiting Screen: A “placeholder” screen that subjects see after they make decisions in a stage and are waiting for other subjects to finish the stage

11、Stages of a Simple Public Goods GamelSubjects are broken into groups of NlSubjects receive their endowmentlSubjects make a choice for contributionlCalculate the size of the total public contribution and multiply by XlReport earnings (endowment kept + share of the public good) to all subjectsBackgrou

12、nd StageStage 1Stage 2programprogramprogramactive screenactive screenOrderofExecutionStep 1: Setting the General Background ParameterslDouble-click on Background to show the General Parameters dialoglSet Number of Subjects to the right size (in this case, 8)lSet Number of Groups to the right size (i

13、n this case, 2)lSet Practice Periods to 0 (we will discuss this later)lSet Paying Periods to 1 (no repetitions of the treatment)Setting the Background Parameters (Continued)lExchange ratelMost economic experiments involve some form of cash rewardlThe reward unit within the program (Experimental Curr

14、ency Units, or ECUs) can be denominated differently than the cash rewardlWe set a 1 ECU = $1 (or “1 Franc”) exchange rate subjects see their real payoffs during the experimentlLump Sum Payment: ECUs you give the subject that can change during the experiment (a “bankroll”)lShow-up Fee: Dollars / Fran

15、cs that are paid at the end of the experiment (XEFS standard is $10)Step 2: Set Non-General Background Parameters for the ExperimentlThink about what variable parameters we have in this experimentlthe number of subjects (gen. background)lthe number of periods (gen. background)lX the “efficiency fact

16、or”lthe size of the endowmentSet these in a list at the top of the program makes them easy to change for different treatmentsCreate a Program to Store the VariableslPlace cursor on SessionlSelect New Program from the Treatment menuCreating a New ProgramlUnder Table select SubjectslCreate two variabl

17、e names for X and the EndowmentlSyntax:lvariablename = number;lPress OKAbout “Tables” of VariableslzTree stores variables in several different tables:lSubjects holds variables that may be different between subjects and between periods (most reliable)lGlobals holds variables that will be the same for

18、 all subjects but may differ between periods (have had trouble with this in the past)lSummary like the subjects table, but used to display running statistics of an experiment for the experimenter on the serverlContracts holds buy and/or sell offers in auctionslSession holds variables that may differ

19、 across subjects but persists across treatmentslIn most cases, the Subjects table is appropriateStep 3: Ask Subjects for ContributionslPlace cursor on BackgroundlSelect New Stage from the Treatment menuCreating a New StagelGive the stage a name, like “Contribution”lUnder the Start menu, select Wait

20、for all (so that all subjects enter stage together)lLeave At most one unchecked (used to make choices sequential)lUnder Leave stage after timeout, select No (makes time limit non-binding)lUnder Timeout, select 30 (seconds)Creating a Screen for Subjects to Enter ContributionlPlace cursor on Active Sc

21、reenlSelect New BoxStandard Box from the Treatment menuTerminologylBox: A container in which text displays and entry buttons are placed on the Active ScreenCreating a New Box1234567Legend of Box Creation Screen1.Label of the box (not shown to subjects)2.Size of the box, in points or percent of the r

22、emaining screen3.Distance away from the (remaining) screen edge in points or percent4.Adjustment of the remaining box (whether to “cut off” the screen above, below, to the left, or to the right of the current box5.Display Condition (if present, Boolean expression that must be true in order for box t

23、o be shown)6.Button Position (where to place buttons in this box)7.Arrangement (how to arrange buttons)Finishing Creation of The BoxPutting an Item into the BoxlPlace cursor on Contribution EntrylSelect New Item from the Treatment menuCreating the Text to DisplayWays to Display Information in an Ite

24、mFinishing the Item Text: A Title BoxA New Item: Showing the EndowmentThe Final Item: An Input Box for ContributionA Button to End the StagelPlace cursor on the last item under Active ScreenlSelect New Button from the Treatment menulSet the button as shownStep 3: Calculate Public GoodlCreate a new s

25、tage, call it “Display Outcomes”lHighlight the new stage, then create a new program lEnter this code into the program:lPgood=Efficiencyfactor*sum(same(Group), Contribution);lNote this command: sum(same(Group), Contribution) this tells the computer to sum up the variable “Contribution” for everyone i

26、n the same GroupMore ProgramslCreate another program under the last one, and enter the following code:lN = count(same(Group);lThis command tells the computer to count the number of people with the same group numberlCreate a new program under the last one, and enter this code in:lProfit = Pgood / N +

27、 (Endowment Contribution);lNote: Profit is a reserved variable name that zTree uses to record the amount paid to a subject (in ECUs) in every periodlPrograms MUST be separate: you cannot use a variable created by a program in another expression until the program has been completely executedStep 4: D

28、isplay OutcomeslCreate a new Standard box, call it “Final Outcome”lSet the box to take up the entire screenlAdd items to the box:lPlace a title on the resultslDisplay the amount the subject keptlDisplay the amount of the subjects own contributionlDisplay the total contribution of the grouplDisplay t

29、he subjects share of the contributionlDisplay the final earnings of the subjectlPut a button in to leave the stageSet Group Matching ProtocollSelect TreatmentParameter TablelSelect all of the cells corresponding to the different subjects in Period 1lSelect TreatmentMatchingStrangerThats It!lSave the

30、 file using FileSavelWe are now ready to run an experimentSuggested HomeworklTry modifying todays program into a “Common Pool Resource” Game (Ostrom et al. APSR article, “Covenants With and Without a Sword”)l8 agents have a given number of work hours in a day (say, 10) and can allocate them between

31、harvesting a common pool resource (x) and leisure (10-x)lCPR yields diminishing returns to increasingly intense harvestinglPayoff = x*(23X-0.25X2)+5(10-x), where X=sum(x) over all subjectsQuestionnairesQuestionnaireslYou must run a questionnaire at the end of an experiment in order to retrieve the d

32、ata from that experimentlQuestionnaires can be simple, just names and social security numbers, or involve more complicated surveyslToday, we will do a simple example of a questionnaire and show more complicated examples laterCreate a QuestionnairelGo to FileNew QuestionnairelDouble-click on “Adress”

33、 (the German spelling of Address, I think)Basic Questions in Questionnaire Questions left blank will not be asked to the subjects.Label on the “OK” ButtonWhat you enter into the blank will correspond to what the header on the answer blank will read; for example, you can use the “Postal Code” blank t

34、o gather information about Social Security NumbersAdding a Final Display ScreenlSelect (single-click) “Adress”, then go to QuestionnaireNew Question FormlYou can add items to this question form, just like you do with a box in a normal treatmentlTypical items to display might include:lThe variable Fi

35、nalProfit total earnings from the experiment, not including the show-up feelThe variable ShowUpFeelCreate items (with labels) to display these variablesThe Final QuestionnaireRunning a SessionRunning an ExperimentlOpen zTree and Treatment Files on the Experimenter ServerlMake sure language is set co

36、rrectlylSet Matching protocol (if necessary)lOpen zLeaf on every Subject computerlMake sure language and names are set up correctly on zLeaf programslCheck to make sure clients are connectedlRun experiment treatmentslMonitor Subjects table and Clients tablelRun questionnaire; read Payment fileslColl

37、ect data and split tableszTrees Advantage: Easy NetworkinglAll you need to do is open zTree on the experimenter PC first, then open zLeaf on each client PClMake sure that, in the same directory as zLeaf, there is a notepad file called server.eec with the IP address of the server computer on itSettin

38、g Language and Name on zLeaflCreate a shortcut to the zLeaf on each Subject clientlIn the Target blank, put in:l/Name lPut in a different name for each Subject client computer so that you can tell them apartVerifying that Clients are Connected: The Clients TableEight Clients (Named Correctly) Are Co

39、nnected to this ServerStarting the TreatmentMonitor Subject ProgresslThe Clients table and the Subjects table provide most of the important informationOpening the Subjects TableCurrent Stage that Subject is inTime Remaining in StageVariable Values for Each SubjectInformation in Client and Subject Ta

40、blesStarting the QuestionnaireThe “Adress” Form ShownThe Payment FilelOnce every subject has finished the questionnaire (as you can monitor in the Clients table) a payment file will be writtenlOpen this file in Excel to see payoffsPayment File DetailsCollecting and Organizing the DatalzTree names fi

41、les according to date plus a random code:lYYMMDDCC.xxxlY = Year, M = Month, D = Day, C = codelSeveral files are of interestlSubject file: .sbj (Questionnaire answers stored here)lGamesafe: .gsf (Internal zTree Storage)lCollected Tables: .xls (Variables from Treatment)Split Tables/Treatments ApartlCl

42、ose zTreelMake sure zTree is really closed (use Ctrl-Alt-Delete and close any instances of zTreelRe-open zTree, select ToolsSeparate TablesSelect the .xls file from the last treatmentNew Files CreatedTreatment NumberTable NameSample Treatment RunlOn your desktop, create a shortcut to zLeaflCall it /

43、Name , where I give you the numberHow can you test programs on your own?lOpen your treatment with zTreelOpen as many zLeaf Shortcuts on your own computer as necessary to run the treatmentlName them differently to help differentiate themlRun treatment in zTree as normal, switching among zLeafs (using

44、 Alt-Tab) to make entriesMore Complicated Programs: Functions and Simple Control StatementsGuess the Sine FunctionzTree Implements Many Mathematical FunctionszTree also Implements Many “Table” FunctionsAnother Example: A “Guess the Average” GameThe Scope Operator Within TablesThe Scope Operator Betw

45、een TableslSuppose that the above program is being executed in table A, and that there is a variable v present in tables A, B, and ClNote that the syntax B.function() executed in table A draws variables from table B for execution; the scope operator moves the execution to the next higher tableTechni

46、ques: Ranking SubjectsGive subjects a rank ties go to a lower numberGive subjects a rank ties go to a higher numberIn the case of a tie, reward subject according to their “average” rankRanking Subjects & the Scope OperatorAs the function works through each line of the table, compare the value of

47、 Diff for each subject in the table to the value of Diff for the subject on this lineProgramming in Group Matching Automatically Using a FunctionRank subjects according to a random variable, then assign them into groups according to their ranksThe Scope Operator Between TablesTable ATable BTable CCo

48、nditional Execution of ProgramslYou can write programs such that statements are executed only if certain conditions are trueConditionIf c is True, do thisIf c is False, do this(optional)Example of Conditional ExecutionIn this case, the value of the variable p is contingent on the period and the iden

49、tity of the subjectComparison Symbols (if is case sensitive)lif(x=y)lIf x is equal to ylMUST be two signslif(x=y & x=z)lIf “x equals y” AND “x equals z” are both truelif(x=y | x=z)lIf either “x equals y” OR “x equals z” are truelif(x!=y)lIf x is NOT equal to ylif(xy)lIf x is greater than ylif(x=

50、y)lIf x is less than or equal yEntire Programs and Display Boxes Can Also be ConditionalParticipation in a Stage can be ConditionalMore Complicated Programs: Display OptionsRecall Item Layouts Inside of BoxesLayout OptionsIn-Class ExerciselStart with game222.zttlTasks:lMake the Choice Variable a bin

51、ary radio button choicelOnly show the final profit display to the first subjectMore Complicated Item Layouts: Displaying Variables in TextlVariable outputs can be displayed in the “l(fā)abel” portion of a label layoutlIn the “l(fā)abel” portion of the item box, enter code that looks something like this:Tell

52、s program that there will be embedded variables in this textRegular textEmbedded VariableVariable nameLayoutAn Example of Embedding VariablesDouble-Embedding of VariableslThis displays the value of Profit if positive and the text “negative” if it is negativelYou could have put the variable name Prof

53、it in the double-embedding (and I always do), but in this case it is not necessaryFont Size and Formatting in LabelslLabel formatting is controlled using RTF tags (rich text formatting)What will DisplayCodeExample of RTF Formatting: Bankruptcy WarningEmbedded Variables and RTF Formatting TagsNon-Sta

54、ndard BoxesGrid BoxesHelp BoxesHistory BoxesContainer BoxeslA Container box holds other, smaller boxeslUse it to easily organize other boxesContainer boxes divide the screen into columns; boxes in the Container divide the column into cells; one item is placed into each boxExample: Using Container Bo

55、xesMore Complicated Programs: Arrays and IteratorsStoring VectorslzTree can store vectors of values by creating array objectslValues for elements of the array are assigned using this syntax: arraynamei=1;Arrays and Iterator FunctionslArrays can be used in conjunction with iterator functions in order to quickly assign a series of valueslIterators repeatedly execute a portion of a program, incrementing the value of a variable as it goeslIterator statements must be appended to other functions, like “sum” or “do” using a syntax like it

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論