Announcement

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

  • xml_tab does not output required tstat or pvalue

    I use the following code to output regression results.

    Code:
    xml_tab r1, replace drop() below tstat stats(N r2) sheet(Result, color(3) nogridlines) ///
    lines(EST_NAMES 3 COL_NAMES 2 _cons 2 LAST_ROW 3) ///
    rblanks(_cons "FEs: none") ///
    save("$dir\Results\results.xml")
    While I specify "tstat", in the output xml file, the values below coefs are not t statistics. Replacing "tstat" with "pvalue" does change anything. Has anyone experienced this issue?

  • #2
    hello, I meet the same question. Have you solved it? Thanks.

    Comment


    • #3
      Now there is the same issue in STATA18 (most recent version!!) How can we use xml_tab to export t-statistics? It only shows standard errors.

      Comment


      • #4
        Hello, can anyone give some help on this issue? Thank you in advance!

        Comment


        • #5
          since this is a user-written command, and a pretty old one at that, I think you are going to have to write to the author

          Comment


          • #6
            Rich, thanks! I did not know that xml_tab is a user-written command. Do you know whether STATA has its official command of exporting regression results to tables? Thanks again.

            Originally posted by Rich Goldstein View Post
            since this is a user-written command, and a pretty old one at that, I think you are going to have to write to the author

            Comment


            • #7
              I'm not sure I understand what you are asking; however, assuming you are using the current (18) or previous version (17) of Stata (and you really need to tell us if you are not using version 18), then, see the following:
              Code:
              h etable
              h table
              h collect

              Comment


              • #8
                Originally posted by Rich Goldstein View Post
                I'm not sure I understand what you are asking; however, assuming you are using the current (18) or previous version (17) of Stata (and you really need to tell us if you are not using version 18), then, see the following:
                Code:
                h etable
                h table
                h collect
                Rich, thanks for your suggestion. I am using STATA18 now. In the past, I used STATA12 and it works perfect to export the regression tables into excel. The following is my sample code. But now in STATA18, the exported table only shows standard errors (see the attached picture), no p-value or t-stat, even if I specify the "tstat" option in the xml_tab command. I am really confused where the problem is. Is it because of STATA18 or my code?

                sysuse auto
                regress price rep78 length mpg
                estimates store reg1
                regress price rep78 length mpg turn if foreign==1
                estimates store reg2
                xml_tab reg1 reg2, tstat below sheet("Table 2") stats(N r2_a) save(B:\Temp\StataTable\reg_test.xml) replace


                Attached Files

                Comment


                • #9

                  Starting with Stata 17 (as Rich points out), you can use new command
                  etable to produce similar estimation tables and then
                  collect export to publish them to an MS Excel document.

                  Here is how I reproduced your table, but showing the t statistics,
                  using etable.
                  Code:
                  sysuse auto
                  regress price rep78 length mpg
                  estimates store reg1
                  regress price rep78 length mpg turn if foreign==1
                  estimates store reg2
                  
                  etable, estimates(reg1 reg2) ///
                      cstat(_r_b, nformat(%12.3fc)) /// coefficient
                      cstat(_r_z, nformat(%12.3fc)) /// t statistic
                      mstat(N) ///
                      mstat(r2_a) ///
                      column(estimate) ///
                      stars(.01 "***" .05 "**" .1 "*") ///
                      showstars ///
                      showstarsnote
                  
                  collect export reg_test.xlsx, replace sheet("Table 2")
                  Here is the resulting table from the Stata output
                  Code:
                  ---------------------------------------------------
                                             reg1           reg2
                  ---------------------------------------------------
                  Repair record 1978       698.260 **    -342.147
                                             2.047         -0.583
                  Length (in.)              30.681        134.488 ***
                                             1.344          3.221
                  Mileage (mpg)           -178.157 *      -20.389
                                            -1.975         -0.255
                  Turn circle (ft.)                        37.724
                                                            0.123
                  Intercept              1,783.936    -15,796.207
                                             0.297         -1.376
                  Number of observations        69             21
                  Adjusted R-squared          0.24           0.56
                  ---------------------------------------------------
                  *** p<.01, ** p<.05, * p<.1
                  I do not have MS excel on my machine, but here is a screen shot of the
                  resulting spreadsheet from LibreOffice.

                  Click image for larger version

Name:	Screenshot 2023-08-15 at 11.33.11 AM.png
Views:	1
Size:	41.7 KB
ID:	1723869

                  Comment


                  • #10
                    Jeff, awesome! I was trying different ways to figure out the reason of that issue but not get it through. Although xml_tab seems to generate neater tables in EXCEL especially in the case of multiple columns, etable command can also help users save time to export results. Thank you so much for your help!

                    Comment


                    • #11
                      eable HELP

                      I tried to export regression estimates in MS Word using etable syntax. It succeeded; however, if I change the dependent variables for successive regression models (using the same set of independent variables), then the output is visible below the first model's coefficients in the new column (see the pic in the attached file). I would like to see the estimates side by side in a table. Please help me in this regard.
                      I use the following syntax:
                      sysuse auto.dta
                      quietly logistic foreign price mpg rep78
                      estimates store m1
                      quietly reg price mpg rep78 weight foreign
                      estimates store m2
                      etable, estimates(m1 m2) append stars( .01 `"*"' .05 `"**"' .1 `"***"', attach(_r_b _r_p) ) mstat(N) mstat(chi) mstat (ll) mstat (aic) export(myfilen.docx)
                      Attached Files

                      Comment


                      • #12
                        If you add option showeq you will see that the logistic results have equation foreign and the regress results have equation price.

                        Try adding option eqrecode(foreign=xb price=xb).

                        Comment

                        Working...
                        X