Transcription of IMPACT EVALUATION USING STATA - PEP-NET
1 IMPACT EVALUATION USING STATAIH abiba Djebbari and Mar a Adelaida LoperaThis material is a complement to the book IMPACT EVALUATION in Practice. Itconsists of a series of examples illustrating the basic analysis required in a rigor-ous program EVALUATION report. Nonetheless, each EVALUATION has particularitiesthat need to be addressed and researchers are expected to further explore thecaveats of their own program. The required background is a basic knowledgeof the software STATA and some familiarity with statistical document is organized as follows. Chapter 1 is a quick introduction toStata and its programming language. Chapter 2 illustrates the randomizationprocess and how to compute basic power calculations. Chapter 3 shows howto estimate simple program effects.
2 This is an interactive document. The datasets and STATA exercises are available by clicking on the links, complementaryvideos are also accessible by clicking on the iconI. Your comments or sug-gestions can be addressed to Introduction to Getting Started .. Interface .. File Structure .. Introduction to Programming .. Macros .. Loops .. Programs .. Help .. Working with Data .. Summary Statistics and Tables .. Graphics .. 102 Random Experimental Sample .. Replicability of Random Draws .. External Validity .. Treatment and Control Groups .. Stratification .. Level of Randomization .. Internal Validity .. Validation of the Research Design.
3 Clustering .. Power Calculations .. Required Sample Size .. Clustering and Required Sample Size .. Power of the EVALUATION .. 233 Program IMPACT Outcome Variable .. Average Treatment Effect .. Heterogenous IMPACT .. Quantile Treatment Effect .. Unintended Effects .. 293 Chapter 1 Introduction to Getting StartedThis chapter is a review of the STATA software. This is not an extensive manual butan overview of some of the elements required in a program InterfaceIThe STATA interface is composed of four windows. There is a menu and a toolbarat the top. Use either of these to open the datasets and the command files. Youcan use theCommandwindow to enter commands, although most of the timewe will directly execute them from the do-file.
4 To execute a single commandfrom a do-file, highlight it and click on File StructureIThere are four types of STATA files. Those identified by the suffix*.dtacontaindata. The*.dofiles contain STATA commands. You can replicate the examplesin each section by executing the corresponding do-file. The*.logfiles recordthe output. Finally, the*.adofiles are fancy do-files that you do not want to dealwith for to Introduction to ProgrammingProgramming has quite a high fixed cost. However, if you are planning to useStata often, your investment will totally pay off. Your do-files will be concise,comprehensible, replicable and easily MacrosIWhen programming you manipulate a special type of object holds information in memory aside from the dataset; the concept is similarto a variable in other programming languages.
5 There are two type of macros:localandglobal. Our first local macro is namedworldand contains the wordmundo. Use the symbols` to recall a local macro and the commanddisplayto printout its world = "mundo"display "hola world "(output)hola mundoMacros can also contain numbers or a list of elements:local numerator = 1+sqrt(5)local denominator = 2display "golden number = " numerator / denominator (output)golden number = list1 = "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377"local list2 = "El ingenioso hidalgo don Qvixote de la Mancha, 1605"display " list1 "display " list2 "(output)0 1 1 2 3 5 8 13 21 34 55 89 144 233 377El ingenioso hidalgo don Qvixote de la Mancha, 1605 Global macros are not very different from local ones.
6 All you need to knowat this stage is that global macros stay in memory for longer. To recall a globalmacro, use the dollar sign ($).5 Introduction to Stataglobal golden = (1+sqrt(5)) / 2display $golden(output) LoopsIA loop executes the commands enclosed in its braces many times. There arethree main types of loops:forvalues, which iterates over a series of numbers,foreach, which iterates over the elements of a list, andwhile, which iteratesuntil a condition is evaluated as false. These three loops are useful for all sorts ofrepetitive tasks. Our first loop sets the local macronto values from 1 to 10. Eachloop sets to the power ofnthegolden numberdefined n = 1 (1) 10 {display $golden^ n }(output) second loop iteratively sets the local macrowordto each element ofthelist2defined above.
7 The_continuecommand suppresses the automaticnewline at the end of each word in list2 {display " word " _continue}(output)El ingenioso hidalgo don Qvixote de la Mancha, 1605 For the third loop, we set the starting values of two counters (i=0,j=1) anddefine a stopping condition (i<1500). The loop displays the counters values ateach round until the condition is evaluated as to Statalocal i = 0local j = 1while i < 1500 {display i " " _continuedisplay j " " _continuelocal i = i + j local j = i + j }(output)0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 ProgramsIProgramming is an advanced topic. After reading this section, you will be ableto read and modify basic STATA programs according to your particular first program is calledgreetings.
8 It gives a particular value to the localmacrohelloand displays it. Before creating the program we have to erase anyother program with the same name. Any program code has to be enclosedbetween two commands:program (..) end. To run it, we simply write theprograms program drop greetingsprogram greetingslocal hello = "hola"display " hello "endgreetings(output)holaWhatever follows the program s name will be taken by STATA as its the example below, the programratiohas two arguments. STATA will automat-ically name all the arguments with positional macros, in this case:`1 and`2 .When we execute the programratiofollowed by the numbers 6 and 3, the pro-gram divides the first argument by the program drop ratioprogram ratiodisplay "ratio = " 1 / 2 endratio 6 3(output)ratio = 27 Introduction to StataTherclassoption saves inr()any value preceded by the outputr()can be used as an argument in other numerator = 1+sqrt(5)local denominator = 2capture program drop divideprogram divide, rclassreturn local ratio = 1 / 2 enddivide numerator denominator display "golden number = " r(ratio)(output)golden number = HelpITheHelptool contains precious information on commands and is often recom-mended as great leisure reading.
9 One of STATA s strengths is the consistency ofits command syntax. Most commands share the following structure:[prefix:] command [varlist][if][in][weight][, options]The square brackets[ ]indicate a non-mandatory argument. The suffixvarlistis a list of variables; when not specified, all the variables are used. Thesuffixesifandinrestrict the set of observations used by the command. Mostcommands accept prefixes that modify their task, one of the most commonbeingby. Theoptionsare always specified after a semicolon and modify whatthe command Working with DataIThe examples in this document are based on a subsample from the BangladeshHousehold Survey 1991/92-1998/99 (Khandker et al., 2010). This sections uses by resetting the memory with theclear allcommand.
10 Then, specifythe current directory path on the computer USING thecdcommand. Obviously,you need to indicate your own computer to Stataclear allcd C:\Users\your \ STATA Practice\data\ Summary Statistics and TablesThe commanduseopens the " "Explore the data USING the commandsdescribe,summarize,tabulate,andc odebook. Try to add some options to the commands USING the STATA exptotsum exptot, detail(output omitted)The variableexptotmeasures total household expenditures and the variablesexheadidentifies the gender of the household heads. This last one takes avalue of 1 if the head of the household is a man and 0 if it is a sexheadtabulate sexhead(output)Variable | Obs Mean Std. Dev. Min Max-------------+----------------------- ---------------------------------sexhead | 583.