»  Home »  Products »  Stata 17 »  Tables of estimation results

Tables of estimation results

Highlights

  • Create tables of

    • Single-model estimation results
    • Multiple-model estimation results
    • Marginal predictions
    • Marginal predictions and coefficients
  • Flexible ways to create your table

    • Create a table automatically after fitting a model
    • Append results to an existing table
    • Create tables from stored estimation results
    • Reproduce an existing table with new customizations
  • Customize the table

    • Customize statistics, format, column header, title, note, and more
    • Finer customizations using collect
  • Export the table

    • Word®
    • Excel®
    • PDF
    • HTML
    • LaTeX
    • And more

Stata 17 now allows you to create tables of estimation results easily using etable. Stata does all the work of collecting and organizing results and laying them out into a nice table for you. For instance, you can create the following table by exporting it to LaTeX using etable and then creating a PDF.

Or you can create tables in Word,

Excel,

or HTML,

What’s more, because etable is built on the collect suite of commands, which is designed for customizing any type of table, it is a seamless process to use the collect commands to further customize the look of your tables after you have created them using etable.


Let's see it work

Single-model and multiple-model estimation tables

Let’s get started with a basic one-model table using the NHANES II data (McDowell et al. 1981). After fitting a linear regression model, typing etable directly will create an estimation table.

. webuse nhanes2l, clear
. regress bpsystol age weight i.region
. etable

By default, the table shows the dependent variable in the column header, reports coefficients with standard errors (in parentheses), and displays the number of observations.

  

We can request additional statistics such as confidence intervals for coefficients and the R². We can also add stars to indicate the level of significance and export the estimation table to a .docx file. All of these changes can be made using the cstat(), mstat(), showstars, showstarsnote, and export() options demonstrated in the following command:

. etable, cstat(_r_b) cstat(_r_se) cstat(_r_ci) mstat(N) mstat(r2)
   showstars export("test.docx", replace) showstarsnote

The exported file test.docx looks like

Maybe you are more interested in a table that compares results of multiple models. Here is an example table comparing the coefficients and standard errors from five different logistic regression models.

  

We can create such a table interactively—fitting the models one-by-one and using the append option with etable after fitting each model. The append option asks etable to append the result from the most recent regression model to the previous estimation table we have created. Using the same dataset, we can run the following code to generate this table. This time, we use the column() option in our final etable command to show model indexes in the column header instead of the dependent variable names. We also use the note() option to include a note indicating the name of the dependent variable.

. quietly logistic diabetes age i.sex i.race bmi
. etable

. quietly logistic diabetes age
. etable, append

. quietly logistic diabetes i.sex
. etable, append

. quietly logistic diabetes i.race
. etable, append

. quietly logistic diabetes bmi

. etable, append column(index) showstars showstarsnote
   title(Logistic regression results comparison) note(DV=diabetes)

Alternatively, we can store the results of each regression model using estimates store and create the same table using the estimates stored in memory.

. quietly logistic diabetes age i.sex i.race bmi
. estimates store e1

. quietly logistic diabetes age
. estimates store e2

. quietly logistic diabetes i.sex
. estimates store e3

. quietly logistic diabetes i.race
. estimates store e4

. quietly logistic diabetes bmi
. estimates store e5

. etable, column(index) estimates(e1 e2 e3 e4 e5) showstars showstarsnote
   title(Logistic regression results comparison) note(DV=diabetes)

Tables of marginal results

Besides the parameter estimates from regression models, we can also create tables of results such as marginal means, predictive margins, and marginal effects that are reported by the margins command after fitting a model. To create such a table, you just need to specify the option margins with etable after calling the margins command. For example, the following code generates a table with predictive margins and standard errors for the covariate race. Here we specify the option column(command) to show the command name in the column header instead of the dependent variable name.

. quietly logistic diabetes age i.sex i.race bmi
. margins race
. etable, margins column(command)

  

Just like estimation results, we can add more sets of predictive margins to this table as columns. We can even combine parameter estimates and predictive margins in one table. For example, we can add another set of predictive margins for sex (the third column), as well as the logistic regression coefficients (the first column), to the existing table using the following code:

. quietly logistic diabetes age i.sex i.race bmi
. etable
. margins race
. etable, margins append
. margins sex
. etable, margins column(command) append

  

Customize the look of the table

etable itself has a set of powerful options to customize the look of the table. As we have shown in above examples, we can request the coefficient statistics and model statistics using the options cstat() and mstat(); we can customize the column header using column; we can add stars using showstars; and we can add customized titles and notes using the options title() and note(). Many other options are available as well, such as keep(). Please refer to the manual entry for more detailed information.

etable also has a nice replay feature. Typing

. etable, replay

reports the previous table without consuming results. It will remember all the options you specified before, so you do no need to retype them. You can also add options while reproducing a table. For example,

. quietly logistic diabetes age i.sex i.race bmi
. etable, mstat(N, nformat(%9.0g)) mstat(aic, 
    nformat(%9.3f)) mstat(bic, nformat(%9.3f)) mstat(r2_p, nformat(%9.3f))

. etable, replay column(command) note("DV=diabetes")

The second etable command will create the same table as the full command,

. etable, mstat(N, nformat(%9.0g)) mstat(aic, 
    nformat(%9.3f)) mstat(bic, nformat(%9.3f)) mstat(r2_p, nformat(%9.3f)) column(command) 
    note("DV=diabetes")

  

Further customization using collect

We mentioned that etable is actually built on top of the collect suite of commands. All the table elements are saved in a collection called Etable, and the table layout is arranged by collect. Therefore, all the collect commands such as collect style cell are available after we create an estimation table using etable. This gives us many additional ways to customize the look of our table.

For example, let's continue working with the five-column table we discussed previously. We can produce the following table in HTML using collect commands after calling etable.

To create this table, we type the following commands after the etable command that we used to create the table of regression results:

* Put factor variable's name and each level in a single cell instead of stacking them
collect style row split, binder(" = ")  dups(first)

* Assign a label "Model index" to the dimension cmdset
collect label dim cmdset "Model index", modify

* Display the label of cmdset in the column header
collect style header cmdset, title(label)

* Combine b and se in a composite result called bse
collect composite define bse = _r_b _r_se, trim

* Change the layout to show the composite result bse instead of _r_b and _r_se
* This will display all the coefficient statisitics for each covariate on one row
collect layout (coleq#colname#result[bse] result[N]) (cmdset#stars) (), name(ETable)

* Show the level values of the result dimension. This will affect the row header for
* the observation number
collect style header result[N], level(value)

collect preview

collect export "table", as(html) replace

Export the table

As we have shown in a couple of examples above, the estimation tables created by etable can be easily exported using either the export() option with etable, or using the collect export command to various formats of files, including .docx, .xlsx, .tex, .html, and more.


Reference

McDowell, A., A. Engel, J. T. Massey, and K. Maurer. 1981. Plan and operation of the Second National Health and Nutrition Examination Survey, 1976–1980. Vital and Health Statistics 1: 1144.


Additional resources

You can read more about estimation tables in [R] etable.

To learn more about the collect suite of commands, see the Stata Customizable Tables and Collected Results Reference Manual.



Stata

Shop

Support

Company


The Stata Blog: Not Elsewhere Classified Find us on Facebook Follow us on Twitter LinkedIn YouTube Instagram
© Copyright 1996–2022 StataCorp LLC   •   Terms of use   •   Privacy   •   Contact us