Outreg2(1)
Outreg2(1)
Oscar Torres-Reyna
otorres@princeton.edu
Oscar Torres-Reyna 2
REGRESSION MODELS
Oscar Torres-Reyna 3
Linear regression: single predictor
ssc install outreg2 // do this only once
dir : seeout
Mac users click on “dir” to go to the directory where myreg.doc is saved, open it with Word.
Oscar Torres-Reyna 4
OLS regression: comparing multiple predictors
Adding other predictors, side-by-side comparison (make sure to close myreg.doc)
Oscar Torres-Reyna 6
Logit and probit models
webuse lbw // sample data
Oscar Torres-Reyna 7
Logit model: odds ratio
logit low smoke ht lwt i.race , robust or
outreg2 using mylogit.doc, append label ctitle(Ods ratio) eform
Oscar Torres-Reyna 9
For more details/options and examples type help outreg2
Logit model compare to linear probability model (LPM)
reg low smoke ht lwt i.race , robust
outreg2 using mylogit.doc, append label ctitle(LPM)
For predicted probabilities and marginal effects, see the following document
https://www.princeton.edu/~otorres/Margins.pdf
Oscar Torres-Reyna
OTR 11
PU/DSS/OTR
See also:
asdoc: https://fintechprofessor.com/2018/01/31/asdoc/
tabout: https://ianwatson.com.au/stata/tabout_tutorial.pdf
DESCRIPTIVE STATISTICS
Oscar Torres-Reyna 12
Using outreg2 for summary statistics: all variables in dataset
Mac users click here to go to the directory where x.doc is saved, open it
with Word (you can replace this name with your own)
Oscar Torres-Reyna
For more details/options and examples type help outreg2 13
Using outreg2 for summary statistics: selected variables
Mac users click here to go to the directory where x.doc is saved, open it
with Word (you can replace this name with your own)
Oscar Torres-Reyna
For more details/options and examples type help outreg2 14
Using outreg2 for summary statistics:
selected variables in dataset and selected statistics
Mac users click here to go to the directory where x.doc is saved, open it
with Word (you can replace this name with your own)
Oscar Torres-Reyna
For more details/options and examples type help outreg2 15
Using outreg2 for summary statistics:
selected variables in dataset and detail statistics
Windows users click here to open the file x.doc in Word (you
can replace this name with your own) . Otherwise follow the
Mac instructions.
Mac users click here to go to the directory where x.doc is saved, open it
with Word (you can replace this name with your own)
Oscar Torres-Reyna 16
For more details/options and examples type help outreg2
Using outreg2 for summary statistics:
selected variables in dataset and selected detail statistics
*NOTE: The option “sum(detail)” will give all the summary statistics shown below for
the selected variables but it will show in the output window results for all the
variables in the dataset. This is similar to typing “summarize, detail”
* The option “p50” gives the median
Windows users click here to open the file x.doc in Word (you
can replace this name with your own) . Otherwise follow the
Mac instructions.
Mac users click here to go to the directory where x.doc is saved, open it
with Word (you can replace this name with your own)
Oscar Torres-Reyna 17
For more details/options and examples type help outreg2
Using outreg2 for summary statistics:
by group, selected variables in dataset and detail statistics
*NOTE: You need to specify either keeping statistics (eqkeep) and droping variables
(drop) or viceversa. You can’t specify eqkeep() and keep() at the same time
Windows users click here to open the file x.doc in Word (you
can replace this name with your own) . Otherwise follow the
Mac instructions.
Mac users click here to go to the directory where x.doc is saved, open it
with Word (you can replace this name with your own)
Oscar Torres-Reyna
For more details/options and examples type help outreg2 18
CUSTOM TABLES FOR
DESCRIPTIVE STATISTICS
Oscar Torres-Reyna 19
Numeric and factor variables in one table
sysuse nlsw88.dta // sample data
help table
See:
* https://www.stata.com/manuals/rtablemultiway.pdf#rtablemultiway
* https://www.stata.com/manuals/tablespredefinedstyles.pdf#tablesPredefinedstyles
Oscar Torres-Reyna 20
Numeric and factor variables in one table
Oscar Torres-Reyna 21
Export table to Word
collect set table1 // after running the table command
collect preview
help table
See:
* https://www.stata.com/manuals/rtablemultiway.pdf#rtablemultiway
* https://www.stata.com/manuals/tablespredefinedstyles.pdf#tablesPredefinedstyles
Oscar Torres-Reyna 24
Numeric and factor variables by group
Nonunion Union Total
Mean
Hourly wage 7.20 8.67 7.57
Usual hours worked 37.26 38.66 37.61
Total work experience (years) 12.68 13.25 12.82
Job tenure (years) 6.14 7.89 6.57
Age in current year 39.21 39.28 39.22
Standard deviation
Hourly wage (4.10) (4.17) (4.17)
Usual hours worked (10.23) (9.11) (9.98)
Total work experience (years) (4.62) (4.55) (4.61)
Job tenure (years) (5.41) (6.11) (5.64)
Age in current year (3.04) (3.02) (3.03)
Factor-variable percent
Race
White 74.2% 65.5% 72.0%
Black 24.7% 32.8% 26.7%
Other 1.1% 1.7% 1.3%
Married
Single 33.5% 39.3% 34.9%
Married 66.5% 60.7% 65.1%
Lives in a central city
Not central city 73.0% 62.5% 70.4%
Central city 27.0% 37.5% 29.6%
Lives in the south
Not south 53.2% 70.5% 57.5%
South 46.8% 29.5% 42.5%
Oscar Torres-Reyna 25
Export table to Word
collect set table2 // after running the table command
collect preview
Oscar Torres-Reyna 28
Hypothesis testing
sysuse nlsw88.dta
Group Obs Mean Std. err. Std. dev. [95% conf. interval]
Oscar Torres-Reyna 29
Hypothesis testing
return list
scalars:
r(level) = 95
r(sd) = 4.168369257933639
r(sd_2) = 4.174538873345928
r(sd_1) = 4.1036938325326
r(se) = .2209702313599325
r(p_u) = .9999999999809384
r(p_l) = 1.90616301182e-11
r(p) = 3.81232602363e-11
r(t) = -6.650784018445881
r(df_t) = 1876
r(mu_2) = 8.674294102217784
r(N_2) = 461
r(mu_1) = 7.204668818936856
r(N_1) = 1417
Oscar Torres-Reyna 30
Hypothesis testing
table (command) (result),///
command(Yes=r(mu_2) No=r(mu_1) ///
Difference= (r(mu_2) - r(mu_1)) ///
p_value= r(p): ttest wage, by(union)) ///
nformat(%9.3f) ///
stars(p_value 0.1 "*" 0.05 "**" 0.01 "***",
shownote)
See: https://www.stata.com/manuals/rtablehypothesistests.pdf#rtablehypothesistests
Oscar Torres-Reyna 31
Hypothesis testing, multiple variables
table (command) (result), ///
command(Yes=r(mu_2) No=r(mu_1) Difference= (r(mu_2) - r(mu_1)) p_value = r(p): ttest wage, by(union)) ///
command(Yes=r(mu_2) No=r(mu_1) Difference= (r(mu_2) - r(mu_1)) p_value = r(p): ttest hours, by(union)) ///
command(Yes=r(mu_2) No=r(mu_1) Difference= (r(mu_2) - r(mu_1)) p_value = r(p): ttest ttl_exp, by(union)) ///
command(Yes=r(mu_2) No=r(mu_1) Difference= (r(mu_2) - r(mu_1)) p_value = r(p): ttest tenure, by(union)) ///
command(Yes=r(mu_2) No=r(mu_1) Difference= (r(mu_2) - r(mu_1)) p_value = r(p): ttest age, by(union)) ///
nformat(%9.3f) stars(p_value 0.1 "*" 0.05 "**" 0.01 "***", shownote) name(t_test1) replace
See: https://www.stata.com/manuals/rtablehypothesistests.pdf#rtablehypothesistests
Oscar Torres-Reyna 32
Export table to Word
collect set t_test1 // after running the table command
collect preview