handout stata_tutorial econometrics

Upload: counturn

Post on 10-Feb-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    1/20

    1

    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 recommendedthat 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 DisplayFour 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 messageor 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 clickon 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 .

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    2/20

    2

    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.

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    3/20

    3

    Lets structure this folder in a way that facilitate an organized session in the

    Research Method course.

    Do the following steps:

    Windows ExplorerMy ComputerX FolderEctr_IE&BR_Methods-2013.Double click on the Ectr_IE&BR_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:

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    4/20

    4

    Access to data

    The data needed for the lab sessions are available in different formats,

    accessible from the internet.

    Minimize STATA and enter principles ofeconometrics, fourth edition on

    Googlessearch 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

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    5/20

    5

    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:

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    6/20

    6

    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 onSTATA 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:

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    7/20

    7

    Two things are worth noting:

    The Review sections tells us that the data have been extracted from the

    R_Methods-2013Ectr-IE&B Data 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.

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    8/20

    8

    Keys STATA commands:

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

    If you click on Submit then the nameof the variable will change (see the variable

    section of the STATA opening display).

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    9/20

    9

    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:

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    10/20

    10

    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.

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    11/20

    11

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

    observations.

    Example 2: Summary Statistics for the ownersin the sample.

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    12/20

    12

    STATA Graphics:

    Histograms and scatter diagrams are some of the most common diagrams used in

    applied economics. They represent a powerful tool for a meaningfulldescriptive

    analysis.

    Histograms:

    The histograms can be obtained from STATA tool bar:

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    13/20

    13

    0

    10

    20

    30

    40

    0 500000 1000000 1500000Price

    Distribution of prices

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    14/20

    14

    Scatter Diagram:

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    15/20

    15

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    16/20

    16

    Creating and Managing Variables:

    Example #1: Lprice=log(price)

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    17/20

    17

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    18/20

    18

    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 thedescriptive statistics of price2.

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    19/20

    19

    Example #3: pricepool=pricepool

  • 7/22/2019 Handout STATA_Tutorial Econometrics

    20/20

    20

    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 cChapters11-2of the bBrown bBookusing STATA.2. Replicate the various steps performed during the lab session.