Announcement

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

  • A Solution for Publication Quality Regression Tables (from STATA to .DOC)

    Dear friends,

    I often use Latex to generate publication-quality tables and figures and the STATA-Latex nexus works smoothly for that goal. However, I need to have my tables with .doc files for a while. How can I produce such publication-quality regression tables using STATA 17's built-in solutions?

    The code sample below does not work well.

    Code:
    esttab m1 m2 m3 m4 using "uaetable.doc",  starlevel( * 0.10 ** 0.05 *** 0.010)

  • #2
    "does not work well" is a sub-optimal way of trying to solicit reader interest -- it provides no information about the nature of the error as reported by Stata. (Please read the Forum FAQ.)

    Type help esttab and note the output formats allowed. "doc" is not among them. But "rtf" is, and rtf files can be read by MS Word

    Comment


    • #3
      Nihat:
      as Stephen already flagged, without further details from your side any advice/maintenance suggestion becomes unfeasible.
      That said, I do hope that the following toy-example (that will give you back a .doc table) can be helpful:
      Code:
      . use "https://www.stata-press.com/data/r17/nlswork.dta"
      (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
      
      . xtreg ln_wage i.year c.age##c.age, fe vce(cluster idcode)
      
      Fixed-effects (within) regression               Number of obs     =     28,510
      Group variable: idcode                          Number of groups  =      4,710
      
      R-squared:                                      Obs per group:
           Within  = 0.1162                                         min =          1
           Between = 0.1078                                         avg =        6.1
           Overall = 0.0932                                         max =         15
      
                                                      F(16,4709)        =      79.11
      corr(u_i, Xb) = 0.0613                          Prob > F          =     0.0000
      
                                   (Std. err. adjusted for 4,710 clusters in idcode)
      ------------------------------------------------------------------------------
                   |               Robust
           ln_wage | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
      -------------+----------------------------------------------------------------
              year |
               69  |   .0647054   .0155249     4.17   0.000     .0342693    .0951415
               70  |   .0284423   .0264639     1.07   0.283    -.0234395     .080324
               71  |   .0579959   .0384111     1.51   0.131    -.0173078    .1332996
               72  |   .0510671   .0502675     1.02   0.310    -.0474808     .149615
               73  |   .0424104   .0624924     0.68   0.497    -.0801038    .1649247
               75  |   .0151376    .086228     0.18   0.861    -.1539096    .1841848
               77  |   .0340933   .1106841     0.31   0.758    -.1828994     .251086
               78  |   .0537334   .1232232     0.44   0.663    -.1878417    .2953084
               80  |   .0369475   .1473725     0.25   0.802    -.2519716    .3258667
               82  |   .0391687   .1715621     0.23   0.819    -.2971733    .3755108
               83  |    .058766   .1836086     0.32   0.749    -.3011928    .4187249
               85  |   .1042758   .2080199     0.50   0.616    -.3035406    .5120922
               87  |   .1242272   .2327328     0.53   0.594    -.3320379    .5804922
               88  |   .1904977   .2486083     0.77   0.444    -.2968909    .6778863
                   |
               age |   .0728746    .013687     5.32   0.000     .0460416    .0997075
                   |
       c.age#c.age |  -.0010113   .0001076    -9.40   0.000    -.0012224   -.0008003
                   |
             _cons |   .3937532   .2469015     1.59   0.111    -.0902893    .8777957
      -------------+----------------------------------------------------------------
           sigma_u |  .40275174
           sigma_e |  .30127563
               rho |  .64120306   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      
      . estimates store fe
      
      . etable, estimates(fe) mstat(N) mstat(N_g) mstat(g_max) mstat(F) mstat(r2_w) mstat(r2_b) mstat(r2_o) mstat(r2) mstat(r2_a) mstat(sigma_u) mstat(sigma_e) mstat(rho) showstars showstarsnote title("Table X -xtreg, fe- (Standard errors [SE] within brackets)")
      
      Table X -xtreg, fe- (Standard errors [SE] within brackets)
      ----------------------------------------------------
                                                  ln_wage
      ----------------------------------------------------
      Interview year                                     
        69                                        0.065 **
                                                (0.016)  
        70                                        0.028  
                                                (0.026)  
        71                                        0.058  
                                                (0.038)  
        72                                        0.051  
                                                (0.050)  
        73                                        0.042  
                                                (0.062)  
        75                                        0.015  
                                                (0.086)  
        77                                        0.034  
                                                (0.111)  
        78                                        0.054  
                                                (0.123)  
        80                                        0.037  
                                                (0.147)  
        82                                        0.039  
                                                (0.172)  
        83                                        0.059  
                                                (0.184)  
        85                                        0.104  
                                                (0.208)  
        87                                        0.124  
                                                (0.233)  
        88                                        0.190  
                                                (0.249)  
      Age in current year                         0.073 **
                                                (0.014)  
      Age in current year # Age in current year  -0.001 **
                                                (0.000)  
      Intercept                                   0.394  
                                                (0.247)  
      Number of observations                      28510  
      Number of groups                          4710.00  
      Largest group size                          15.00  
      F statistic                                 79.11  
      R-squared for within model                   0.12  
      R-squared for between model                  0.11  
      R-squared for overall model                  0.09  
      R-squared                                    0.12  
      Adjusted R-squared                           0.12  
      Panel-level standard deviation               0.40  
      Standard deviation of ε_it                   0.30  
      ρ                                            0.64  
      ----------------------------------------------------
      ** p<.01, * p<.05
      
      . putdocx begin
      
      . putdocx collect
      
      . putdocx save Stata_alfa, replace
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        Dear Stephen Jenkins and Carlo Lazzaro,

        I tried the ".rtf" option, and also looked into Carlo Lazzaro's example. Thank you so much for your elegant suggestions and caution.

        Best,

        Comment


        • #5
          You can also try asdoc for exporting tables to MS word. asdoc works with almost all Stata commands. You have to add asdoc to the beginning of Stata commands. Here is an example of a nested regression table.
          Code:
          ssc install asdoc
           use "https://www.stata-press.com/data/r17/nlswork.dta"
          
          asdoc xtreg ln_wage i.year c.age##c.age, fe vce(cluster idcode) nest replace
          Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	20.5 KB
ID:	1668066
          Regards
          --------------------------------------------------
          Attaullah Shah, PhD.
          Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
          FinTechProfessor.com
          https://asdocx.com
          Check out my asdoc program, which sends outputs to MS Word.
          For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

          Comment


          • #6
            how to get t value instead of standard error in above table?

            Comment


            • #7
              Use the option rep(t) when you start the nested table (i.e use both the rep(t) and replace options together). For more options and features, you may also like to explore nested regressions in asdocx.
              Regards
              --------------------------------------------------
              Attaullah Shah, PhD.
              Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
              FinTechProfessor.com
              https://asdocx.com
              Check out my asdoc program, which sends outputs to MS Word.
              For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

              Comment

              Working...
              X