Announcement

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

  • Display R2 with esttab command

    Dear Stata listers,

    in my fixed effects model linear Regression I want to provide r2 within values in the Output table.
    I´m using the esttab command which currently Looks like this:

    xtreg $ylist $xlist i.Year, fe vce(robust)
    eststo: quietly xtreg $ylist $xlist i.Year fe vce(robust)
    estadd local fixed "yes", replace

    xtreg $ylist $xlist age*tenure i.Year, fe vce(robust)
    eststo: quietly xtreg $ylist $xlist age*tenure i.Year, fe vce(robust)
    estadd local fixed "yes", replace

    esttab se(2) b(2) star(* .01 ** .005 *** .01) s(fixed N, Label("Year fixed effects")) drop (*Year)

    The Output provides the Models in one table and Displays everything I wanted correctly: two Point decimals for coefficients and Standard Errors, significance Levels as indicated by stars at the coefficients and a bottom line stating "fixed effects" yes for every model.

    Now, I´d like to add some Information about r2. Most preferably I want to disclose r2 withing because that is the r2 being of interest for the fixed effects model.
    However, I can not figure out a way how to do that. At most I manage to get Overall r2.

    Is it not possible at all to Display the values for r2 within in Connection with the esttab command? If that is the case, could anyone please provide some help?

    Thank you very much,
    Sophie



  • #2
    Sorry I made a mistake with the star Labels, I meant:
    star(* 0.1 ** 0.05 *** 0.01)

    Comment


    • #3
      Code:
      stats(r2_w)

      Comment


      • #4
        Hi Andrew,

        thanks for your Reply. Unfortunately, however, it is not possible to put both commands "stats" and "s(fixed N, Label("year fixed effects")).
        When I try to put both commands, Stata remarks:

        "Option stats() not allowed" if I put the s command first and
        "Option s() not allowed" if I put the stats command first resprectively.

        Alternatively, is there adifferent way to Display the bottom row with "fixed effects = yes" ?

        Thank you,
        Sohpie

        Comment


        • #5
          stats() and s() are one and the same

          Code:
          esttab, se(2) b(2) star(* 0.1 ** 0.05 *** 0.01)  stats(fixed N r2_w, label("Year fixed effects")) drop (*Year)
          So, no commas between displayed statistics (if displaying multiple stats)


          Also, you do not need to accept default names such as "r2_w" because these may not be immediately apparent to the reader. Therefore, you can name a scalar and feed the value of the stat of interest to this scalar, e.g.,

          Code:
          estadd scalar Within_R2= e(r2_w)
          esttab, se(2) b(2) star(* 0.1 ** 0.05 *** 0.01)  stats(fixed N Within_R2, label("Year fixed effects")) drop (*Year)
          Last edited by Andrew Musau; 05 Dec 2017, 08:11. Reason: renaming stats in esttab

          Comment


          • #6
            Thank you so much Andrew!

            Comment


            • #7
              Hello,

              I am having trouble with the code displaying pseudo square in logistic regression using esttab. I tried scalars(r2) and stats(r2) but neither worked.
              Code:
              eststo r1:  logit stem_eh ${covsZ} ,
                              fitstat
                              estadd scalar r2 = r(r2_mz)
                  eststo r2:  logit stem_eh ${covsZ} ${covsA} ${covsB} ,
                              fitstat
                              estadd scalar r2 = r(r2_mz)
                  eststo r3:  logit stem_eh ${covsZ} ${covsA} ${covsB} ${covsC} ${covsD},
                              fitstat
                              estadd scalar r2 = r(r2_mz)
              
              esttab r1 r2 r3 using "logit1.csv", ///
                      b(%9.2fc) se(%9.2fc) scalars(r2)  ///
                      replace label compress nogaps
              Thanks,
              Tingting

              Comment


              • #8
                After running the estimation command, type

                Code:
                ereturn list
                to see how the statistic is named. The pseudo-R2 is "e(r2_p)".

                Comment

                Working...
                X