Announcement

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

  • How to make the following code using esttab and estadd work?

    Hi,

    eststo clear
    eststo xtreg y x z if h=0
    eststo xtreg y x z if h=1
    estadd ?
    esttab using "${OUTPATH}emp_industry" ///
    nomtitles booktabs replace ///
    indicate("Controls = z" "Province FE = _cons" "Industry FE = *.industry" "Industry-year trend = *.industry#c.year" "Province-year trend = *.prov#c.year" "Year FE = *.year", labels("\checkmark" "")) ///
    stats(N ?, labels("Obs. #" "$\R^2$")) ///
    label nobaselevels interaction("\$\times\$") substitute("=1" "") nonotes se star(* 0.10 ** 0.05 *** 0.01)

    The two question marks are the two places that I cannot work out correctly.

    Thank you very much!

  • #2
    You forgot your final ///

    Comment


    • #3
      Jared Greathouse Thanks! How to get the R square from the regression results to the table?

      Comment


      • #4
        estout is from SSC, as you are asked to explain (FAQ Advice #12). You do not need estadd as the statistic is part of the stored estimates, but you need to decide which R2 statistic you want to report. xtreg has 3, so if it is the within:

        Code:
        webuse grunfeld, clear
        xtreg invest mvalue kstock, fe
        ereturn list
        esttab, scalars(N r2_w)
        Res.:

        Code:
        . xtreg invest mvalue kstock, fe
        
        Fixed-effects (within) regression               Number of obs     =        200
        Group variable: company                         Number of groups  =         10
        
        R-sq:                                           Obs per group:
             within  = 0.7668                                         min =         20
             between = 0.8194                                         avg =       20.0
             overall = 0.8060                                         max =         20
        
                                                        F(2,188)          =     309.01
        corr(u_i, Xb)  = -0.1517                        Prob > F          =     0.0000
        
        ------------------------------------------------------------------------------
              invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
              mvalue |   .1101238   .0118567     9.29   0.000     .0867345    .1335131
              kstock |   .3100653   .0173545    17.87   0.000     .2758308    .3442999
               _cons |  -58.74393   12.45369    -4.72   0.000    -83.31086     -34.177
        -------------+----------------------------------------------------------------
             sigma_u |  85.732501
             sigma_e |  52.767964
                 rho |  .72525012   (fraction of variance due to u_i)
        ------------------------------------------------------------------------------
        F test that all u_i=0: F(9, 188) = 49.18                     Prob > F = 0.0000
        
        .
        . ereturn list
        
        scalars:
                       e(r2_w) =  .76675759381787
                        e(F_f) =  49.1766279136348
                       e(rank) =  3
                       e(Tbar) =  20
                       e(Tcon) =  1
                      e(g_min) =  20
                      e(g_avg) =  20
                      e(g_max) =  20
                        e(N_g) =  10
                    e(sigma_u) =  85.73250064497634
                       e(corr) =  -.151724593121521
                       e(r2_o) =  .8059782143252492
                       e(r2_b) =  .8194301765498294
                    e(sigma_e) =  52.76796426523782
                      e(sigma) =  100.6703517404121
                        e(rho) =  .7252501223783426
                          e(p) =  3.74892046727e-60
                        e(p_f) =  8.70011895951e-45
                       e(df_m) =  11
                       e(df_b) =  2
                       e(ll_0) =  -1216.348719738058
                         e(ll) =  -1070.781020103484
                        e(tss) =  9359943.916562427
                       e(df_a) =  9
                       e(r2_a) =  .753110431754022
                        e(rss) =  523478.1139071142
                        e(mss) =  1720874.113784922
                       e(rmse) =  52.76796426523782
                         e(r2) =  .76675759381787
                          e(F) =  309.0141925675344
                       e(df_r) =  188
                          e(N) =  200
        
        macros:
                    e(cmdline) : "xtreg invest mvalue kstock, fe"
                        e(cmd) : "xtreg"
               e(marginsnotok) : "E U UE SCore STDP XBU"
                    e(predict) : "xtrefe_p"
                      e(model) : "fe"
                        e(vce) : "conventional"
                       e(ivar) : "company"
                     e(depvar) : "invest"
                 e(properties) : "b V"
        
        matrices:
                          e(b) :  1 x 3
                          e(V) :  3 x 3
        
        functions:
                     e(sample)  
        
        .
        . esttab, scalars(N r2_w)
        
        ----------------------------
                              (1)  
                           invest  
        ----------------------------
        mvalue              0.110***
                           (9.29)  
        
        kstock              0.310***
                          (17.87)  
        
        _cons              -58.74***
                          (-4.72)  
        ----------------------------
        N                     200  
        r2_w                0.767   
        ----------------------------
        t statistics in parentheses
        * p<0.05, ** p<0.01, *** p<0.001
        
        .

        Comment


        • #5
          Andrew Musau Thank you very much! It works well.

          Comment

          Working...
          X