Scottish Social Survey Network: Master Class 1 Data Analysis with Stata Dr Vernon Gayle and Dr Paul...
-
Upload
alice-morrison -
Category
Documents
-
view
219 -
download
3
Transcript of Scottish Social Survey Network: Master Class 1 Data Analysis with Stata Dr Vernon Gayle and Dr Paul...
![Page 1: Scottish Social Survey Network: Master Class 1 Data Analysis with Stata Dr Vernon Gayle and Dr Paul Lambert 23 rd January 2008, University of Stirling.](https://reader036.fdocuments.us/reader036/viewer/2022062407/56649e745503460f94b74ba0/html5/thumbnails/1.jpg)
Scottish Social Survey Network: Master Class 1
Data Analysis with Stata
Dr Vernon Gayle and Dr Paul Lambert23rd January 2008, University of Stirling
The SSSN is funded under Phase II of the ESRC Research Development Initiative
![Page 2: Scottish Social Survey Network: Master Class 1 Data Analysis with Stata Dr Vernon Gayle and Dr Paul Lambert 23 rd January 2008, University of Stirling.](https://reader036.fdocuments.us/reader036/viewer/2022062407/56649e745503460f94b74ba0/html5/thumbnails/2.jpg)
Introducing Stata
Windows environmentOpening and processing commands – the
do-file editorOpening and saving dataViewing data Preserving outputs (logs)Tips (and wrinkles)Further examples on our website
![Page 3: Scottish Social Survey Network: Master Class 1 Data Analysis with Stata Dr Vernon Gayle and Dr Paul Lambert 23 rd January 2008, University of Stirling.](https://reader036.fdocuments.us/reader036/viewer/2022062407/56649e745503460f94b74ba0/html5/thumbnails/3.jpg)
STATA SOFTWARE – GOOD POINTS
• Does all the simple stuff (SPSS)
• Fits many more models than standard software (esp. Longitudinal)
• Specialist survey analysis functions (Svy)
• You can get started easily (menus and help)
• Strong documentation
• There is a growing user community (lists etc)
• New features emerge almost daily
• There are good labour market opportunities (UK little known; USA well known)
![Page 4: Scottish Social Survey Network: Master Class 1 Data Analysis with Stata Dr Vernon Gayle and Dr Paul Lambert 23 rd January 2008, University of Stirling.](https://reader036.fdocuments.us/reader036/viewer/2022062407/56649e745503460f94b74ba0/html5/thumbnails/4.jpg)
Main data window
Command window – interactive use
Variable names
Review – what you’ve done
![Page 5: Scottish Social Survey Network: Master Class 1 Data Analysis with Stata Dr Vernon Gayle and Dr Paul Lambert 23 rd January 2008, University of Stirling.](https://reader036.fdocuments.us/reader036/viewer/2022062407/56649e745503460f94b74ba0/html5/thumbnails/5.jpg)
Open the do file editor (or ‘ctrl-8’) A Do File (.do)
![Page 6: Scottish Social Survey Network: Master Class 1 Data Analysis with Stata Dr Vernon Gayle and Dr Paul Lambert 23 rd January 2008, University of Stirling.](https://reader036.fdocuments.us/reader036/viewer/2022062407/56649e745503460f94b74ba0/html5/thumbnails/6.jpg)
Highlight the command and run it from the icon
(or ctrl D)
![Page 7: Scottish Social Survey Network: Master Class 1 Data Analysis with Stata Dr Vernon Gayle and Dr Paul Lambert 23 rd January 2008, University of Stirling.](https://reader036.fdocuments.us/reader036/viewer/2022062407/56649e745503460f94b74ba0/html5/thumbnails/7.jpg)
Opening and Saving Data
• use “C:\data\dataset2.dta”
• save “C:\data\dataset2.dta”
To overwrite…
• use “C:\data\dataset2.dta”, clear
• save “C:\data\dataset2.dta”, replace
![Page 8: Scottish Social Survey Network: Master Class 1 Data Analysis with Stata Dr Vernon Gayle and Dr Paul Lambert 23 rd January 2008, University of Stirling.](https://reader036.fdocuments.us/reader036/viewer/2022062407/56649e745503460f94b74ba0/html5/thumbnails/8.jpg)
variables names & descriptions
![Page 9: Scottish Social Survey Network: Master Class 1 Data Analysis with Stata Dr Vernon Gayle and Dr Paul Lambert 23 rd January 2008, University of Stirling.](https://reader036.fdocuments.us/reader036/viewer/2022062407/56649e745503460f94b74ba0/html5/thumbnails/9.jpg)
Data Windows
Data browser (can’t edit here)
Data editor (dangerous - can edit here)
![Page 10: Scottish Social Survey Network: Master Class 1 Data Analysis with Stata Dr Vernon Gayle and Dr Paul Lambert 23 rd January 2008, University of Stirling.](https://reader036.fdocuments.us/reader036/viewer/2022062407/56649e745503460f94b74ba0/html5/thumbnails/10.jpg)
Data Editor (familiar spreadsheet)
![Page 11: Scottish Social Survey Network: Master Class 1 Data Analysis with Stata Dr Vernon Gayle and Dr Paul Lambert 23 rd January 2008, University of Stirling.](https://reader036.fdocuments.us/reader036/viewer/2022062407/56649e745503460f94b74ba0/html5/thumbnails/11.jpg)
Log files (keeping track)
log using “C:\data\temp1.log”, replace
![Page 12: Scottish Social Survey Network: Master Class 1 Data Analysis with Stata Dr Vernon Gayle and Dr Paul Lambert 23 rd January 2008, University of Stirling.](https://reader036.fdocuments.us/reader036/viewer/2022062407/56649e745503460f94b74ba0/html5/thumbnails/12.jpg)
Using Stata – Some tips
• Session settings– set more off (once in command window)– set mem 64M (, permanently)
• Data overwrite– use dataset1.dta, clear– save dataset1.dta, replace
• Do not double click on .do files in windows they will crash
• Generate variables– drop varname before gen varname
• See values and labels– numlabel _all, add
• File information– codebook
![Page 13: Scottish Social Survey Network: Master Class 1 Data Analysis with Stata Dr Vernon Gayle and Dr Paul Lambert 23 rd January 2008, University of Stirling.](https://reader036.fdocuments.us/reader036/viewer/2022062407/56649e745503460f94b74ba0/html5/thumbnails/13.jpg)
Using Stata – Some tips
• File locations– global path1 "d:\lda\work\" – use “$path1\data1.dta”, clear
• Output– capture – suppresses output (*including errors*)– nolog – e.g. suppresses interactions in logit– noheader - suppresses the display of the ANOVA table etc in regression– nodots – jacknife “not a lot of people know that”
• Line breaks– /// tells Stata to read the next line too
• Looking at the data– edit– browse– list in1/10 – shows data for cases 1 to 10
![Page 14: Scottish Social Survey Network: Master Class 1 Data Analysis with Stata Dr Vernon Gayle and Dr Paul Lambert 23 rd January 2008, University of Stirling.](https://reader036.fdocuments.us/reader036/viewer/2022062407/56649e745503460f94b74ba0/html5/thumbnails/14.jpg)
STATA SOFTWARE – BAD POINTS
• Poor data visualisation (compared with SPSS etc)• In practice, survey analysis functionality comes with
limitations (complex methods but weak data) • There are some models that can’t be fitted / some
critiques of estimation procedures• Stata syntax has some quirks (set more off)• There is a growing user community, but they are
generally GEEKBOYS (like myself!)• New features emerge almost daily these are sometimes
tricky to get to grips with
![Page 15: Scottish Social Survey Network: Master Class 1 Data Analysis with Stata Dr Vernon Gayle and Dr Paul Lambert 23 rd January 2008, University of Stirling.](https://reader036.fdocuments.us/reader036/viewer/2022062407/56649e745503460f94b74ba0/html5/thumbnails/15.jpg)
Taking Stata further
• Online resources– Stata website for FAQs, manual, training– Net use and update
• Specialist modelling suites– XT – Cross sectional panel– ST – Survival data– SV – Survey data– Xtmixed - Multilevel models (v9)– GLLAMM
• Programming: .do; .ado; macros