Sei sulla pagina 1di 20

STATA Introductory Session

1. Settings: Set up the English settings (, for thousands, . For decimals, etc.) a. StartSettingsControl PanelRegional and language optionsEnglish (US). 2. Get access to STATA: a. Make a shortcut to Download STATA on your desktop. WWhy? To avoid any idle time during the remaining lab sessions. b. Close all applications and have your desktop on the screen c. StartRUG MenuTools and UtilitiesNAL (NOVELL Application Launcher). i. Two windows appear on your screen. Select Mathematics and Statisctics icon on the left window. ii. Highlight the STATA icon and drag it on your desktop. Warning: From now on it is your responsibility to have STATA up and running prior to any lab session. It is recommended that you log on your computer a few minutes before the beginning of the lab session. If you waste time fiddling with STATA in the early minutes of a quiz you are NOT going to get any extra time!. 3. Starting STATA Double click on the STATA icon to launch the STATA software. a. The Opening Display Four windows, each of which dedicated for a specific task: CommandThe area where STATA commands are typed ReviewLists the commands recently executed VariablesLists the names of variables entered ResultsOutcome of the execution. This could be statistical output or an Could be error message or statistical output. Also, the STATA tool bar menu. As new users of STATA, you are going to make an intensive use of this tool bar. It is very convenient as it contains many built-in STATA commands. For example, consider File on the tool bar menu, scroll down and select Change Working DirectoryYou see several folders. Select My Computer, then click on the X drive, and then click on the icon Make New Folder. A New Folder has been created. Give it the name Ectr_IE&BR_Methods-2013.

Note: Ensure that write EctrR_Methods-2013IE&B on the highlighted area The result looks like this:

Once you have replace the name Folder with Ectr_IE&BR_Methods-2013, the result looks like this:

This will be your working directory for the course. 2

Lets structure this folder in a way that facilitate an organized session in the Research Method course. Do the following steps: Windows ExplorerMy ComputerX Folder Ectr_IE&BR_Methods-2013. Double click on the Ectr_IE&B R_Methods-2013 folder. Then click on File on the toolbar, scroll down until New and then click on Folder. The result looks like this:

Write on the highlighted area Data and click once anywhere on the screen. At the same time, we can create other folders that may turn out to be necessary. For example, just like the way you created Data, click on FileNewResults, etc. The end result is like this:

Access to data The data needed for the lab sessions are available in different formats, accessible from the internet. Minimize STATA and enter principles of econometrics, fourth edition on Googles search engine. The result looks like this:

The section Data files comprises a wide range of datasets in various formats: ASCII, EViews, STATA, EXCEL, etc. Click on STATA and you get the following screen which contains individual datasets. The screen also allows you to proceed with a batch download of the entire datasets. To

the extent that we have to work with all kinds of datasets, downloading the entire datasets would be our preferred option. The screen looks like this:

Therefore, click on ZIP format. A zip file will be downlowaded and once you click on it you get the following result:

Click on the Extract all files icon, follow the Wizard extraction instruction while ensuring that you point to the Data directory. Check that the files with the dat extension have been downloaded in the Data directory. Then make sure that STATA will automatically point to this directly: FileChange Working Directoryall the way to the Data directory and then click OK. Put the cursor on the folder Open on STATA toolbar and you should be able to see all of the datasets.

Getting started with STATA

Lets get started by selecting one particular dataset, say, br2.dat: Filebr2.dta. STATA opening display looks like this:

Two things are worth noting: The Review sections tells us that the data have been extracted from the R_Methods-2013Ectr-IE&BData directory (squarred area). The dataset contains a series of variables names and the way they are measured (circled area).

If you click on the Data Editor (follow the arrow) then you have acces to the data points, though with no possibility to make any change.

Keys STATA commands: Rename a variable: For example price with nprice, i.e. nominal price.

If you click on Submit then the name of the variable will change (see the variable section of the STATA opening display).

Summary Statistics: This is a first building block of the empirical analysis. It provides a wealth of information on the dataset and its underlying variables.

The screen display provides window:

You can then use the pull-down menu to select the variables. If you click on Submit the main screen display shows:

Note that if you double click on Command 2 in the Command display, the command will appear on the Cammand display. Press enter and you get the same result. You can also type in [summarize price sqft bedrooms baths] in Command display and get the same result as if you go through the STATA menu tool bar. Sometimes you can be interested in descriptive statistics of only a subset of the entire dataset.

10

Example 1: Summary Statistics for the first 100 observations instead of the 1080 observations.

Example 2: Summary Statistics for the owners in the sample.

11

STATA Graphics: Histograms and scatter diagrams are some of the most common diagrams used in applied economics. They represent a powerful tool for a meaningfull descriptive analysis. Histograms: The histograms can be obtained from STATA tool bar:

12

Distribution of prices
40 Percent 0 10 20 30

500000 Price

1000000

1500000

13

Scatter Diagram:

14

15

Creating and Managing Variables: Example #1: Lprice=log(price)

16

17

Example #2: age2=ageage This can be done in two different ways Same process as above Alternatively, make use of a short cut. For example, suppose I want to obtain the descriptive statistics of price2.

18

Example #3: pricepool=pricepool

19

Example #4: Summary statistics on individual variables as well as on a full set of interactions: pool, age and waterfront

Do on your ownTake Home Duties: 1. Read and work through cChapters 11-2 of the bBrown bBook using STATA. 2. Replicate the various steps performed during the lab session.

20

Potrebbero piacerti anche