>
# Multiple-equation Tables
The standard output from `sem` and `gsem` (as well as
generalized linear model commands such as `ologit` and
`mlogit`) present the results for multiple equation models
in one long column. Each equation is stacked, one underneath
the next. Sometimes it facilitates our presentation to
display the equations side by side, particularly if there
are common independent variables that predict different
responses.
We can approach this task with either Stata\'s `estimates
store` and `estimates table` commands, or through Ben Jann\'s
`esttab` command. The first approach requires a little more
set up coding by the user, while the second approach requires
the user to install the `estout` package.
Both commands include options to modify the numeric format,
as well as include or suppress a variety of statistics.
For saving tables to include in other documents, `esttab`
incorporates several useful options.
## Estimates table
First we\'ll set up an example, where a latent variable `X`
is measured by four binary indicators. We will assume the
indicators have probit distributions. So we have four
response variables predicted by a common independent variable.
Notice the standard results are presented in one long column.
~~~~
<>
webuse gsem_1fmm
quietly gsem (x1 x2 x3 x4 <- X), probit
gsem
<>
~~~~
In order to rearrange our equations side by side using
Stata\'s `estimates table` we are going to treat our
results ***as if*** they came from four separate models,
and then specify how they are to be **matched** (aligned)
using the `equation` option. We also specify a `keep`
option - otherwise `estimates table` will display a lot
of redundant information.
The estimates stores are strategically named for each
response variable.
~~~~
<>
estimates store x1
estimates store x2
estimates store x3
estimates store x4
estimates table x1 x2 x3 x4, eq(1:2:3:4) keep(X _cons)
<>
~~~~
## Esttab
Now we'll repeat the same model presentation using `esttab`.
Assuming you already have the `estout` package installed, we
simply construct a table from the current estimates (indicated
by the \" . \") using the `unstack` option. For this particular
model we also drop the latent variance, with the obscure-looking
`drop` option, and suppress the t statistics.
~~~~
<>
esttab ., unstack drop(/:) not
<>
~~~~
## Saving Tables to Include in other Documents
If you want to save your results in a form that makes a nice
table for inclusion in another document, `esttab` can save
tables in a number of formats.
Unstacking can produce really wide tables, so figuring out
what sort of table you can use in a document may be a
challenge. In this example I save to an `html` table so I
can include it in *this* document. If my goal was to put it
in a Word document, I might try saving as `rtf` or `csv`.
For this example I suppress all the cutpoints in the final table.
Note the keyword for ***saving*** a file is `using`, which is
not typical Stata.
~~~~
<>
use "http://www.stata-press.com/data/r15/gsem_cfa", clear
quietly gsem (MathAb -> q1-q8, logit) ///
(MathAtt -> att1-att5, ologit)
gsem, noheader
esttab . using "test", unstack ///
drop(/: /att1: /att2: /att3: /att4: /att5:) ///
compress html replace not
<>
~~~~
And the (really wide) table:
(scrollbar at the bottom)
<>
<>