Announcement

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

  • Trouble with 'esttab' and stats() ... Statistics omitted from Table

    Hello everyone, I seem to be having some trouble with esttab. Any idea why my statistic is loading in blank into the table? As you can see, Stata sees the e(r2_a) ... but it's not loading the value into the table cell. Can someone tell me what I'm doing wrong?


    Code:
    di e(r2_a)
    
    esttab    tfk_total_pctd_Trips_pp ///
        using "$DIR_RESULTS\test", replace nogaps   /// .csv
        mtitles("% Trips/Pers.") ///
        varwidth(20) modelwidth(40) ///
        starlevels(* .05 ** .01 *** 0.001) ///
        stats(N N_clust r2_a) //
    Stata Command Window:
    Code:
    . di e(r2_a)
    .24608608
    
    . 
    . esttab  tfk_total_pctd_Trips_pp ///
    >         using "$DIR_RESULTS\test", replace nogaps /// .csv
    >         mtitles("% Trips/Pers.") ///
    >         varwidth(20) modelwidth(40) ///
    >         starlevels(* .05 ** .01 *** 0.001) ///
    >         stats(N N_clust r2_a) //
    (output written to C:\_GitHub-Repos\VC2-Stata\1-Rev\Results\test.txt)
    But then I get the follow table in test.txt...

    Code:
    ----------------------------------------------------------------
                                                              (1)   
                                                    % Trips/Pers.   
    ----------------------------------------------------------------
    pctd_Trips_pp_hat                                       1.013***
                                                        (0.00392)   
    Shutdown                                                0.126*  
                                                         (0.0604)   
    Testing_Cap                                          -0.00144   
                                                       (0.000912)   
    Pct_hospUtil                                           -5.352***
                                                          (1.171)   
    Unemp_Claims_p1k                                   -0.0000136   
                                                       (0.000562)   
    SearchTrend_Covid                                    0.000528   
                                                        (0.00109)   
    ----------------------------------------------------------------
    N                                                        2805   
    N_clust                                                   145   
    r2_a                                                            
    ----------------------------------------------------------------
    Standard errors in parentheses
    * p<.05, ** p<.01, *** p<0.001

  • #2
    Dear Robert,

    It is curious that the adjusted R2 is not being displayed in your table. That being said, it is hard to discern what the problem is since I don't have all your code or the data set.

    Another potential solution may be to use the estadd command in Stata. This allows you to manually add values to be displayed in esttab tables. The code would look some thing like this:


    * Here is your regression command line...

    estadd scalar r2_adj = e(r2_a)

    esttab ..., stats(N N_clust r2_adj)


    To clarify, the estadd command should be called after your regression. r2_adj is just an example of a name you could give to the value. It could be anything. Then you include this name in the stats() option to be displayed.

    I believe the estadd command is included with the estout file download from ssc.

    I hope this helps.

    Best,
    Salvatore

    Comment


    • #3
      Hi Salvatore, thanks for the tip. I actually tried doing just what you said using the estadd command before I posted... that didn't work either.

      I'm happy to share more code snippets if it might be helpful. These results are being reported from xtivreg2.

      Comment


      • #4
        Just in case you didn't get the memo, the quickest way to resolve your issue is by providing a reproducible example. Also note that estout is from SSC as you are asked to explain (see FAQ Advice #12 on both points).

        Comment


        • #5
          Thanks, Andrew. Every time I post I try to be as precise as possible... but it seems like I always miss something. I'll try to track down an MWE where I can reproduce the error.

          When you say, "you are asked to explain" ... do I mean that I forgot to say "I'm using estout from SSC in Stata 17" ... per FAQ 12.1?
          -- I can now see why that might be helpful.

          Thanks for the friendly suggestions... I aspire to be a more complete poster here!

          Comment


          • #6
            Originally posted by Robert Niewoehner View Post
            When you say, "you are asked to explain" ... do I mean that I forgot to say "I'm using estout from SSC in Stata 17" ... per FAQ 12.1?
            Yes, just in case someone following this thread wants to try out some suggested code, it is important for them to know that there is a community-contributed command that needs to be installed beforehand.

            Comment


            • #7
              I note that the
              Code:
              esttab    tfk_total_pctd_Trips_pp ///
              command generates its report using the estimation set previously stored as tfk_total_pctd_Trips_pp while the
              Code:
              di e(r2_a)
              command displays the adjusted R-squared from the currently active estimation set.

              Perhaps those are different estimation sets. Trying
              Code:
              estimates restore tfk_total_pctd_Trips_pp
              di e(r2_a)
              ereturn list
              might confirm that adjusted R-squared was not returned by the command whose estimation results are stored as tfk_total_pctd_Trips_pp.

              Comment


              • #8
                Originally posted by Andrew Musau View Post

                Yes, just in case someone following this thread wants to try out some suggested code, it is important for them to know that there is a community-contributed command that needs to be installed beforehand.
                That makes total sense! Thank you for the gentle tip.

                William Lisowski ... excellent observation. I'm investigating this, will report back soon.

                Comment


                • #9
                  Upon further investigation, I have confirmed William Lisowski 's hypothesis. During the ivreg2 estimation, multiple estimation sets [can be] saved. In my case, two estimation sets were saved, and even though it appeared that the most recent set, which returned e(r2_a), was the same set that I was trying to access with esttab ... the two sets were not the same. Thank you, William Lisowski and Andrew Musau for your help and guidance.

                  I also found these two other links helpful in trying to figure out how to save the first-stage results of a 2SLS regression. In both, Andrew Musau provides very helpful guidance in accomplishing the primary objective.
                  Save both first- and second-stage results after (xt)ivreg2 by outreg2? - Statalist
                  xtivreg2 export first and second stage results - Statalist

                  Comment

                  Working...
                  X