This FAQ illustrates the outreg command that makes regression tables in a format that is commonly used in journal articles. The outreg command was written by John Luke Gallup and appears in the Stata Technical Bulletin #49. You can download outreg from within Stata by typing search outreg (see How can I use the search command to search for programs and get additional help? for more information about using search).
Let’s illustrate use of the outreg command using the high school and beyond data file we use in our Stata Classes.
use https://stats.idre.ucla.edu/stat/stata/notes/hsb1, clear (highschool and beyond (200 cases))
We will run three regression models predicting the variable read. The first model will predict from the variable write, the second model will predict from math and write, and the third model will predict from socst, math, and write. We will use outreg to create a single table that will summarize these models side by side.
regress read write Source | SS df MS Number of obs = 200 ---------+------------------------------ F( 1, 198) = 109.52 Model | 7450.28755 1 7450.28755 Prob > F = 0.0000 Residual | 13469.1324 198 68.0259215 R-squared = 0.3561 ---------+------------------------------ Adj R-squared = 0.3529 Total | 20919.42 199 105.122714 Root MSE = 8.2478 ------------------------------------------------------------------------------ read | Coef. Std. Err. t P>|t| [95% Conf. Interval] ---------+-------------------------------------------------------------------- write | .64553 .0616832 10.465 0.000 .5238896 .7671704 _cons | 18.16215 3.307162 5.492 0.000 11.64037 24.68394 ------------------------------------------------------------------------------
Here we use outreg to capture the results from the prior model, storing the output in the file test.doc and indicate we want to replace test.doc if it already existed.
outreg using test.doc, replace
Now we run our second regression model.
regress read math write Source | SS df MS Number of obs = 200 ---------+------------------------------ F( 2, 197) = 96.80 Model | 10368.63 2 5184.31501 Prob > F = 0.0000 Residual | 10550.79 197 53.5573096 R-squared = 0.4956 ---------+------------------------------ Adj R-squared = 0.4905 Total | 20919.42 199 105.122714 Root MSE = 7.3183 ------------------------------------------------------------------------------ read | Coef. Std. Err. t P>|t| [95% Conf. Interval] ---------+-------------------------------------------------------------------- math | .5196538 .0703972 7.382 0.000 .380825 .6584826 write | .3283984 .0695792 4.720 0.000 .1911828 .4656141 _cons | 7.541599 3.26819 2.308 0.022 1.096471 13.98673 ------------------------------------------------------------------------------
We run outreg again to capture the results of the second model, merging these results to the previous ones in test.doc.
outreg using test.doc, merge
Now we run our third regression model.
regress read science socst math write Source | SS df MS Number of obs = 195 ---------+------------------------------ F( 4, 190) = 65.23 Model | 11608.8938 4 2902.22346 Prob > F = 0.0000 Residual | 8453.08565 190 44.4899245 R-squared = 0.5787 ---------+------------------------------ Adj R-squared = 0.5698 Total | 20061.9795 194 103.412265 Root MSE = 6.6701 ------------------------------------------------------------------------------ read | Coef. Std. Err. t P>|t| [95% Conf. Interval] ---------+-------------------------------------------------------------------- science | .2657521 .0648044 4.101 0.000 .1379236 .3935806 socst | .2808959 .0581116 4.834 0.000 .1662691 .3955227 math | .2961578 .0743467 3.983 0.000 .1495068 .4428087 write | .1141745 .0724559 1.576 0.117 -.0287468 .2570959 _cons | 2.001966 3.163988 0.633 0.528 -4.239088 8.243021 ------------------------------------------------------------------------------
We run outreg again to capture the results of the third model.
outreg using test.doc, merge
The contents of test.doc look like those below. Tabs are used between columns to get the columns to line up, so you will need to adjust your tab settings to get the tables to look as you desire.
|
read |
read |
read |
write |
0.646 |
0.328 |
0.114 |
|
(10.47)** |
(4.72)** |
(1.58) |
math |
|
0.520 |
0.296 |
|
|
(7.38)** |
(3.98)** |
science |
|
|
0.266 |
|
|
|
(4.10)** |
socst |
|
|
0.281 |
|
|
|
(4.83)** |
_cons |
18.162 |
7.542 |
2.002 |
|
(5.49)** |
(2.31)* |
(0.63) |
R2 |
0.36 |
0.50 |
0.58 |
N |
200 |
200 |
195 |
* p<0.05; ** p<0.01