* STATA class, do-file by Ryoko Ito (itoryoko@gmail.com, www.itoryoko.com)
* Select command, then Ctrl + D.
* View current directory
pwd
* Generate variables
generate exper =.
generate male =.
generate school =.
generate wage =.
* Paste in data using "Data Editor"
* Get summary statistics of data
summarize exper male school wage
* Or "summarize" command does all variables
* Plot histogram of wage data
hist wage
* Scatter plot, wage against experience
twoway (scatter wage exper)
* Save it as "Graph"
* Scatter plot, wage against school
twoway (scatter wage school)
* Save it as "Graph2"
* Log transform of wage data
generate lwage = log(wage)
* Plot histogram of lwage
hist lwage
* Remove lwage
drop lwage
* Correlation stats
correlate
correlate wage exper
correlate wage school
* OLS regression
regress wage exper male school
* Save regression residual and fitted values
predict resa, r
predict yhat
* Scatter plot, wage against residual
twoway (scatter wage resa)
* Test parameter restrictions: exper = school
testparm exper school, equal
* Test parameter restrictions: exper = 3
test (exper = 3)
* Remove all variables and regression outcomes
clear