Announcement

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

  • Getting the number of the groups and overall R-squared from RE in the result table

    Dear All,

    I want to export random effect regression result into Word table. I use estout from SSC. I run regression for 3 models m1 m2 m3 and stored it using eststo. I know how to get the number of observations. However, I don't know how to tell Stata to export number of groups and overall R-squared. I use the code:

    Code:
    esttab m1 m2 m3 using results.rtf, ///
    cells(b(star fmt(%9.3f)) se(par) ///
    stats( N, fmt(%9.3f, %9.0fc) labels("Observations")) ///
    ​​​legend collabels(none) varlabels(_cons Constant) ///
    note(Standard errors are in parentheses.) ///
    title({\b Table1.}) replace
    I know when I put N after stats Stata will take the number of observations. I didn't find the abbrevation for the overall R-squared and number of groups.

  • #2
    Guest,

    have you already taken a look at the new -table- suite?
    Last edited by sladmin; 28 Aug 2023, 08:35. Reason: anonymize original poster
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you for your answer Carlo. I'm sorry but new -table- suite doesn't sound familiar to me. I googled it but found nothing. If you could provide me with the link or a hint where to look I would be grateful

      Comment


      • #4
        Emila:
        assuming that you're working with Stata 17, just type -help table- and take a look at the related entries in Stata .pdfr manual.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          After estimating any of your three random effects regression, type -ereturn list- to see the results that Stata has stored. For example, using the random effects example from Stata's help for -xtreg, re- :

          Code:
          clear
          webuse nlswork 
          xtset idcode 
          xtreg ln_w grade age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure c.tenure#c.tenure 2.race not_smsa south, re theta
          ereturn list
          I see in the results window:

          Code:
          . ereturn list
          
          scalars:
                         e(rank) =  11
                         e(df_m) =  10
                         e(chi2) =  9244.735826836899
                            e(p) =  0
                      e(sigma_u) =  .2579052592523687
                      e(sigma_e) =  .2906892282370427
                        e(sigma) =  .3886069352997693
                          e(rho) =  .440452726681115
                         e(rmse) =  .2904426239253425
                            e(N) =  28091
                         e(Tbar) =  3.292459474371592
                         e(Tcon) =  0
                          e(N_g) =  4697
                        e(g_min) =  1
                        e(g_avg) =  5.980625931445603
                        e(g_max) =  15
                     e(thta_min) =  .2519710745439819
                       e(thta_5) =  .2519710745439819
                      e(thta_50) =  .5498871394578555
                      e(thta_95) =  .7016329908849215
                         e(r2_w) =  .171484938061179
                         e(r2_b) =  .4784030188110969
                         e(r2_o) =  .3707694091066819
                     e(thta_max) =  .7205721155454422
          These returned results are likely to include the statistics you would like to report in your table. The -table- suite of commands that Carlo Lazzaro references rely on these saved results to produce tables.

          But long before Stata added the -tables- suite, Ben Jann contributed -esttab- that you are using and his companion utility -estout-. The command -esttab- can report any of these returned statistics using its option -stats()-. This behavior is documented in the help file for Jann's -estout-. To go directly to the relevant section, in Stata type:

          Code:
          help estout##sum
          For example, the overall R^2 is saved as e(r2_o). So the -esttab- syntax is:

          Code:
          . esttab, stats(r2_o)
          
          ----------------------------
                                (1)   
                            ln_wage   
          ----------------------------
          grade              0.0646***
                            (36.30)   
          
          age                0.0368***
                            (11.80)   
          
          c.age#c.age     -0.000713***
                           (-14.27)   
          
          ttl_exp            0.0290***
                            (11.98)   
          
          c.ttl_exp#~p     0.000305** 
                             (2.62)   
          
          tenure             0.0393***
                            (22.36)   
          
          c.tenure#c~e     -0.00200***
                           (-16.80)   
          
          2.race            -0.0531***
                            (-5.31)   
          
          not_smsa           -0.131***
                           (-18.23)   
          
          south             -0.0869***
                           (-11.90)   
          
          _cons               0.239***
                             (4.83)   
          ----------------------------
          r2_o                0.371   
          ----------------------------
          t statistics in parentheses
          * p<0.05, ** p<0.01, *** p<0.001
          Even better, you can replace the cryptic abbreviation -r2_o- with a more comprehensible label like this:

          Code:
          . esttab, stats(r2_o, labels("Overall R^2"))
          
          ----------------------------
                                (1)   
                            ln_wage   
          ----------------------------
          grade              0.0646***
                            (36.30)   
          
          age                0.0368***
                            (11.80)   
          
          c.age#c.age     -0.000713***
                           (-14.27)   
          
          ttl_exp            0.0290***
                            (11.98)   
          
          c.ttl_exp#~p     0.000305** 
                             (2.62)   
          
          tenure             0.0393***
                            (22.36)   
          
          c.tenure#c~e     -0.00200***
                           (-16.80)   
          
          2.race            -0.0531***
                            (-5.31)   
          
          not_smsa           -0.131***
                           (-18.23)   
          
          south             -0.0869***
                           (-11.90)   
          
          _cons               0.239***
                             (4.83)   
          ----------------------------
          Overall R^2         0.371   
          ----------------------------
          t statistics in parentheses
          * p<0.05, ** p<0.01, *** p<0.001

          Comment


          • #6
            Thank you both for your kind help

            Comment

            Working...
            X