Publication Style Regression Output in Stata– Part 1

Reporting Publication Style Regression Output In Stata

Stata has a nifty command called outreg2 that allows us to output our regression results to other file formats. This command is particularly useful when we wish to report our results in an academic paper and want the same layout we typically see in other published works. In this particular article we are going to understand how to report regression output in Stata. Because outreg2 is a user-written command, we need to install it (just once) if it has not already been done so. The command can be installed simply by entering:

Download Example File
ssc install outreg2

To see how the command works, we will load the 1978 Automobile data from Stata through:

sysuse auto.dta, clear

Where the option of clear ensures that any previous data in Stata’s memory that might still be loaded is erased.

It is good practice to observe the characteristics of the data before doing any data analysis on it. Let’s therefore describe the data through:

describe
Describing the auto data set

This gives you a summary of data characteristics (variable types, labels, etc.).

Exporting Results Through outreg2

Let us proceed towards using outreg2 by first running the following OLS regression, where the variable ‘price’ is regressed on five other independent variables:

regress price mpg headroom trunk gear_ratio displacement

To export the regression output in Stata, we use the outreg2 command with the given syntax:

outreg2 using results, word
simple regression output using outreg2 command
Related Book: Microeconometrics Using Stata by Colin Cameron

using results indicates to Stata that the results are to be exported to a file named ‘results’. The option of word creates a Word file (by the name of ‘results’) that holds the regression output. You can also specify options of excel and/or tex  in place of the word option, if you wish your regression results to be exported to these formats as well.

Following the command, a link called ‘results.rtf’ would appear in your Stata window, clicking on which will open a word processing file with the regression results in a table. In addition to regression coefficients, the table also reports their standard errors, R-squared, and the number of observations.

Another link, ‘dir’ will take you to the folder where the word file with the regression output was actually saved. If you are working in a do-file and have already saved it in a folder, Stata will save the ‘results’ file in the same folder. Alternatively, you can define a working directory for the Stata file you are working in through:

cd “directory link”

Where ‘directory link’ contains the file path of the folder you want to specify.

A third way to save the file to specific directory is specifying the file path in the outreg command:

outreg2 using E:\abc\results, word
Related Article: Using Putexcel to Export Stata Results into Excel

Options: replace and append

Typically, outreg2 is used with other options, most common of which are replace and append.

replace replaces any existing file that has the same name as the one defined in the outreg2 command. In our example, if the working directory already had a word file called ‘results’, running outreg2 with this option would replace that existing file with the one containing the regression results. To illustrate, let’s run a second regression and output it in a word file the same name as before:

regress price mpg headroom trunk displacement
outreg2 using results, word replace
example of replace option

The file called ‘results’ will now have the output data for this regression only, because the replace option replaced the results stored in previously.

The append option is used to add new columns to the existing ones in the file name specified. To illustrate this, let’s run the last regression again, but with an option of robust. This option is used to cater to heterosckedasticity issues by reporting robust standard errors. For this regression, we want the coefficients (and standard errors) to be appended as a new column in the ‘results’ word file:

regress price mpg headroom trunk displacement, robust
outreg2 using results, word append
example of append option

The word file will now have two columns.

Another regression with append option will make this clearer

regress price mpg headroom
outreg2 using results, word append
another example of append option

The results from this third regression will be added/appended to the ‘results’ file as a third column.

Naming Columns with Customised Titles: ctitle()

To distinguish each column with outputs from different regressions, we can specify customised headings accordingly.  For this, we make use of another option called ctitle(). Running the last two regressions, and outputting them with this additional option by:

regress price mpg headroom trunk displacement
outreg2 using results, word replace ctitle(OLS)
regress price mpg headroom trunk displacement,robust
outreg2 using results, word append ctitle(Robust)
example of column title

To illustrate the use of ctitle(), we used the replace option with the first outreg2 command here to replace the previous word file we had created.

Now let’s say, you want to give an additional heading to each regression output column that would help you refer to and identify the model in your paper by, for example,  ‘Model 1’ and ‘Model 2’.

regress price mpg headroom trunk displacement
outreg2 using results, word replace ctitle(Model 1, OLS)
regress price mpg headroom trunk displacement,robust
outreg2 using results, word append ctitle(Model 2, Robust)
column title option with additional row

For the first column, the title will have ‘Model 1’ in its first line, and ‘OLS’ in its second line. The comma between the two titles ensures they are both on separate lines.

Using Variable Labels

Due to variable naming restrictions in Stata, our variables have names that are, though intuitive, often ambiguous. When reporting regression results in a table, it is usually a good idea to replace these variable names with their accompanying variable labels, which are more descriptive and comprehensible, particularly in publications. To have variable labels as row titles in our regression output tables, we simply specify the label option:

regress price mpg headroom trunk displacement
outreg2 using results, word replace ctitle(Model 1, OLS) label
regress price mpg headroom trunk displacement,robust
outreg2 using results, word append ctitle(Model 2, Robust) label
labels instead of variable names

Our table now reports variable labels instead of variable names.

Adjusting Decimal Places

The output table reports coefficients and standard errors with varying formats of decimal numbers, whereby the decimal places in each figure differs. In order to ensure a consistent format is followed, say two decimal places, we specify the dec() option, with our desired number of decimal places in the brackets:

regress price mpg headroom trunk displacement
outreg2 using results, word replace ctitle(Model 1, OLS) label dec(2)
regress price mpg headroom trunk displacement,robust
outreg2 using results, word append ctitle(Model 2, Robust) label dec(2)
reducing number of digits after decimal points

All reported coefficients and standard errors now have two digits after the decimal point.

What if you wanted the standard errors to have a different format than the coefficients reported? Though rarely needed, the outreg2 command allows two separate options for such a specification:

regress price mpg headroom trunk displacement
outreg2 using results, word replace ctitle(Model 1, OLS) label bdec(2) sdec(3)
regress price mpg headroom trunk displacement,robust
outreg2 using results, word append ctitle(Model 2, Robust) label bdec(2) sdec(3)
details of decimal option

The difference in this case are the bdec()and sdec()options. These are built-in options, more of which exist for other statistics and that can be studied in the documentation of outreg2 command through:

help outreg2
other decimal options that can be used

bdec() is specifically for specifying decimal places for regression coefficients, while the  sdec() option for standard errors.

Adding/Removing Notes In Output Tables

In case you need to add extra notes on perhaps details for certain variables, or comments about your regressions, Stata has another option that allows you to do just that.

regress price mpg headroom trunk displacement
outreg2 using results, word replace ctitle(Model 1, OLS) label dec(2) addnote(Model 1 represents results of OLS. Model 2 have robust standard errors)
regress price mpg headroom trunk displacement,robust
outreg2 using results, word append ctitle(Model 2, Robust) label dec(2)
adding a note example

The above command adds a note saying “Model 1 represents results of OLS. Model 2 have robust standard errors” at the bottom of the table in the word file.

Note that the note was added as an option to only the first outreg2 command. You can add it to any one of your outreg2 commands, but not on more than one.

If you do not want any note under your table, including the one on significance levels and p-values that is added by default, you can use the nonotes option:

outreg2 using results, word replace ctitle(Model 1, OLS) label dec(2) nonotes

Adding a Title To Your Table

To add a heading/title to your table, use the title() command, where the parenthesis will contain your title. As with adding notes, this only needs to be added to only one of the outreg2 commands:

regress price mpg headroom trunk displacement
outreg2 using results, word replace ctitle(Model 1, OLS) label dec(2) title(Factors Determining the Car Price)
regress price mpg headroom trunk displacement,robust
outreg2 using results, word append ctitle(Model 2, Robust) label dec(2)
adding a title option

Note that if your title contains commas, you must encase it in quotes: “ ”. Like we observed in ctitle(), adding commas will make any word proceeding the comma appear in the next line. Unless you want that, any title that has commas must be written within quotation marks.

Click here to checkout other interesting option in outreg2.

Subscribe
Notify of
guest
5 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Cynthia
Cynthia
1 year ago

This post is helpful, thanks for sharing. However, I’m experiencing a challenge. I have the results alright but when I add the syntax to export the feedback is, ‘invalid’ word. Please any help?

TheDataHall
Admin
1 year ago
Reply to  Cynthia

Can u please share your code, or email me the do file at info.com

Kevin DeLoughry
Kevin DeLoughry
3 years ago

I’m trying to use stata in citrix and outreg2 refuses to work. Error message says the txt files can’t open. Can I get around this in any way?

TheDataHall
Admin
3 years ago

Can you share the code that you are trying to execute

L J
L J
2 years ago

How do I outreg export 2 tables to the same word document?

5
0
Would love your thoughts, please comment.x
()
x
Tweet
Share
Share
Pin