Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to combine two regression tables in STATA

    After estimating two regression models I want to report them in one table. I am using esttab but unable to sort it out.

    Actually, this is what I am doing. Suppose I want to do a separate regression for domestic and foreign cars as follows
    sysuse auto
    eststo:reg price rep78 mpg if foreign==1
    eststo:reg price rep78 mpg if foreign==0
    eststo:reg weight rep78 mpg if foreign==1
    eststo:reg weight rep78 mpg if foreign==0
    esttab using priceTable.rtf, se r keep (rep78)
    Then Stata gives me the following table.
    (1) (2) (3) (4)
    price price weight weight
    rep78 871.4 330.4 257.1** 54.94
    (581.4) (494.8) (73.56) (61.45)
    N 21 48 21 48
    But my desired table is below one, which I get after some work using the word.

    (1) (2)
    price weight
    Foreign Cars
    rep78 871.4 257.1**
    (581.4) (73.56)
    N 21 21
    Domestic Cars
    Rep78 330.4 54.94
    (494.8) (61.45)
    N 48 48
    Standard errors in parentheses
    * p < 0.05, ** p < 0.01, *** p < 0.001


    Could you help me on how I can get the second table directly from stata?


    Thank you!



  • #2
    I don't think any of the conventional procedures for writing tables will do the table you want. Whether one of the newer ones like asdoc or the new procedures in the Reporting manual will do this I don't know. I often find it easier to set up the tables manually so I can do whatever I want with the labels and so forth and then copy and paste from outreg2 output into the tables.

    Comment


    • #3
      Thank you join. But I read that it is possible to do using esttab package of stata.


      For instance, the below command is supposed to do this but it failed for me.




      sysuse auto, clear
      local count = 1
      foreach sample in "" "if foreign==1" "if foreign==0" {
      eststo clear
      foreach set in "mpg" "mpg trunk" "mpg trunk headroom" "mpg trunk headroom length" {
      eststo: regress price `set' `sample'
      estadd ysumm
      }
      esttab _all using Panel`count'.tex, style(tex) keep(mpg) ///
      stats(N r2 ymean ysd, fmt( %9.0g %9.2f %9.2f %9.2f) ///
      labels("\$N$" "\$R^2$" "Mean of outcome" "St. dev. of outcome")) label ///
      drop() replace se r2 star( * .1 ** .05 *** .01) b(%9.5f) se(%9.5f) ///
      mtitles("\makecell{Base\\ (1)}" "\makecell{+trunk\\(2)}" "\makecell{+headroom\\(3)}" "\makecell{+length\\(4)}" ) ///
      nonotes addnotes("\begin{minipage}{.8\linewidth} \footnotesize \smallskip \textbf{Note:} Table reports regression estimates about cars. Significance levels are indicated by $*$ $<.1$, ** $<.05$, *** $<.01$. \end{minipage}" )
      local ++count
      }
      include "https://raw.githubusercontent.com/steveofconnell/PanelCombine/master/PanelCombine.do"
      panelcombine, use(Panel1.tex Panel2.tex Panel3.tex) columncount(5) paneltitles("Full sample" "Foreign cars" "Domestic cars") save(combined_table.tex) cleanup

      Thank you!

      Comment

      Working...
      X