Research Methods Lecture 5 Advanced STATA - PowerPoint PPT Presentation

About This Presentation
Title:

Research Methods Lecture 5 Advanced STATA

Description:

Research Methods Lecture 5 Advanced STATA IAN WALKER Module Leader S2.109 i.walker_at_warwick.ac.uk – PowerPoint PPT presentation

Number of Views:300
Avg rating:3.0/5.0
Slides: 23
Provided by: IanW56
Category:

less

Transcript and Presenter's Notes

Title: Research Methods Lecture 5 Advanced STATA


1
Research Methods Lecture 5Advanced STATA
  • IAN WALKER
  • Module Leader
  • S2.109 i.walker_at_warwick.ac.uk

2
Housekeeping announcement
  • Stephen Nickell (MPC and LSE)
  • British Academy Keynes Lecture in Economics
  • "Practical Issues in UK Monetary Policy
    2000-2005"
  • Wednesday 2nd November
  • Arts Centre Conference Room at 5.30pm 
  • http//www2.warwick.ac.uk/fac/soc/economics/forums
    /deptsems/keynes_lecture/

3
Stat-Transfer
  • Use STAT-TRANSFER to convert data.
  • Click on
  • Stat-transfer is point and click.
  • Just tell it the file name and format
  • and the format you want it in.
  • Click transfer.

4
Stat Transfer options
  • Useful options for creating a manageable dataset
    from a large one
  • Keep or drop variables
  • Change variable format
  • E.g. float to integer
  • Select observations
  • E.g. where (income benefits)/famsize lt 4500
  • Can be used for reading a large STATA dataset
    and writing a smaller one
  • Avoids doing this in STATA itself

5
Practicising
  • You can import some of Statas own demo files
    using the .sysuse command
  • E.g. .sysuse auto
  • Many datasets are available at specific websites
  • E.g. STATAs own site has all the demo data used
    in the manual examples
  • You can use the .webuse command to load the files
    directly into stata without copying locally
  • .webuse auto / gets the data from STATAs own
    site /
  • Or .webuse set http//www2.warwick.ac.uk/fac/soc/
    economics/pg/modules/rm/notes/auto.dta

6
More help
  • You can search the whole of STATAs online help
    using .search xxx
  • Michigans web-based guide to STATA (for SA)
  • UCLA resources to help you learn and use STATA
  • including movies and web-books
  • Consult other user-written guides and tutorials
  • Chevalier1, Chevalier2 Princeton Illinois
    Gruhn
  • ESDSs Stata for LFS
  • Statas own resources for learning STATA
  • Stata website, journal, library, archive
  • http//www.stata.com/links/resources1.html

7
Web resources
  • STATA is web-aware
  • E.g. . update / updates from www.stata.com /
  • Statalist is an email listserv discussion group
  • The Stata Journal is a refereed journal
  • Replaces the old Stata Technical Bulletin (STB)
  • SSC Boston College STATA Archive
  • Extensive library of programs by Stata users
  • Files can be downloaded in Stata using . ssc
  • Eg .ssc install outreg
  • Installs the outreg ado file that makes tables
    pretty

8
Always (whatever the software)
  • Use lowercase
  • Open a log file
  • Label your data
  • Use the do file editor
  • Organise your files
  • Separate directories for separate projects
  • Archive (zip) data, do and results files when
    your finished

9
Customising STATA
  • profile.do runs automatically when STATA starts
  • Edit it to include commands you want to invoke
    every time
  • .set mem 200m
  • .log using justincase.log, replace
  • Define preferences for STATAs look and feel
  • Click on Prefs in menu
  • Colours, graph scheme, etc.
  • Save window positioning

10
Regression models - I
  • Linear regression and related models when the
    outcome variable is continuous
  • OLS, 2SLS, 3SLS, IV, quantile reg, Box-Cox
  • Binary outcome data
  • the outcome variable is 0 or 1(or y/n)
  • probit, logit, nested logit...
  • Multiple outcome data
  • the outcome variable is 1, 2, ...,
  • conditional logit, ordered probit

11
Regression models - II
  • Count data
  • the outcome variable is 0, 1, 2, ..., occurrences
  • Poisson regression, negative binomial
  • Choice models
  • multinomial choice
  • A, B or C
  • Multinomial logit, Random utility model,
    unordered probit, nested logit, ...etc
  • Selection models
  • Truncated, censored
  • Tobit, Heckman selection models
  • linear regression or probit with selection

12
Regression models - III
  • STATA supports several special data types.
  • Once type is defined special commands work
  • Time series
  • Estimate ARIMA, and ARCH models
  • Estimators for autocorrelation and
    heteroscedasticity
  • Estimate MA and other smoothers
  • Tests for auto, het, unit roots - h, d, LM, Q,
    ADF, P-P ..
  • TS graphs
  • sysuse tsline2, clear
  • tsset day
  • tsline calories, ttick(28nov2002 25dec2002 ,
    tpos(in))
  • ttext(3470 28Nov2002 Thanks" 3470 25dec2002
    Xmas"",orient(vert))

13
gives
14
Special data types survey
  • Non-randomness induces OLS to be inefficient
  • STATA can handle non-random survey data
  • see the syv commands
  • Example (stratified sample of medical cases)
  • . webuse nhanes2f, clear
  • . svyset psuid pweightfinalwgt,
    strata(stratid)
  • . svy reg zinc age age2 weight female black
    orace rural
  • . reg zinc age age2 weight female black orace
    rural

15
(No Transcript)
16
Special data types duration
  • Survival time data
  • See the st commands
  • .stset failtime /sets the var that defines
    duration/
  • Estimates a wide variety of models to explain
    duration
  • E.g. Weibull hazard model -

17
Weibull example .
  • ST regression supports Weibull, Cox PH and other
    options
  • . streg load bearings, distribution(weibull)
  • After streg you can plot bthe estimated hazard
    with
  • . stcurve, cumhaz
  • STATA allows functions to be plotted by
    specifying the function
  • twoway (function y .5x(-.5), range(0 5)
    yvarlab("a.5") )
  • ( function y 1.5x(.5), range(0 5)
    yvarlab("a1.5") )
  • ( function y 1x(0), range(0 5) yvarlab("a1")
    )
  • ( function y 2x, range(0 2) yvarlab("a2") )
  • , saving(weib1, replace)
  • title("Weibull hazard lambda1, alpha varying")
  • ytitle(hazard) xtitle(t)

18
gives..
19
Special data types Panel data
  • STATA can handle panel data easily
  • see the xt commands
  • Common commands are
  • .xtdes Describe pattern of xt data
  • .xtsum Summarize xt data
  • .xttab Tabulate xt data
  • .xtline Line plots with xt data
  • .xtreg Fixed and random effects

20
Panel data
  • An xt dataset looks like this
  • pid yr_visit fev age sex height
    smokes
  • ------------------------------------------
    ----------------
  • 1071 1991 1.21 25 1 69
    0
  • 1071 1992 1.52 26 1 69
    0
  • 1071 1993 1.32 28 1 68
    0
  • 1072 1991 1.33 18 1 71
    1
  • 1072 1992 1.18 20 1 71
    1
  • 1072 1993 1.19 21 1 71
    0
  • xt commands need to know the variables that
    identify person and wave
  • . iis pid
  • . tis yr_visit
  • Or use the tsset command
  • . tsset pid yr_visit, yearly

21
Panel regression
  • Once STATA has been told how to read the data it
    can perform regressions quite quickly
  • . xtreg y x, fe
  • . xtreg y x, re

22
Further advice
  • See Stephen Jenkins excellent course on duration
    modelling in STATA
  • See Steve Pudneys excellent course on panel
    data modelling in STATA
  • Beware the dataset is 30mb
Write a Comment
User Comments (0)
About PowerShow.com