Announcement

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

  • Struggeling with esstab output for regression

    Hi guys!

    I have a question might be extremely easy fix.
    I am trying to create a regression table for several models that displays (R-squared and F for my OLS regressions and AIC en loglikelihood voor Logit regressions).

    Only issue is this is how it is reporting it atm.


    Click image for larger version

Name:	Screenshot 2021-06-07 at 19.30.33.png
Views:	1
Size:	312.8 KB
ID:	1613618


    And this is the command I use (Maybe you guys can help me how I can fix it such that it actually shows F statistic with p value, and the log likelihood values
    Click image for larger version

Name:	Screenshot 2021-06-07 at 19.31.23.png
Views:	1
Size:	94.4 KB
ID:	1613619


    Would appreciate any help

  • #2
    estout is from SSC (FAQ Advice #12). If the P value is less than 0.001, then you will have a lot of "0.000" values in the P value row. It's just better to star the statistic, same as the coefficients. regress does not store the P value corresponding to the model's F-statistic, so you can use testparm to retrieve it. Here is an example that stars the F-statistic.

    Code:
    sysuse auto, clear
    eststo m1: regress mpg weight disp
    testparm *
    
    estadd local Fstat = cond(r(p)<0.01,"`:di %5.3f `=e(F)''***", ///
    cond(r(p)<0.05,"`:di %5.3f `=e(F)''**", ///
    cond(r(p)<0.1,"`:di %5.3f `=e(F)''*",  "`:di %5.3f `=e(F)'''")))
    
    esttab m1, stats(N r2 aic Fstat, labels(Observations R-squared AIC F))
    Res.:

    Code:
    . esttab m1, stats(N r2 aic Fstat, labels(Observations R-squared AIC F))
    
    ----------------------------
                          (1)  
                          mpg  
    ----------------------------
    weight           -0.00657***
                      (-5.63)  
    
    displacement      0.00528  
                       (0.54)  
    
    _cons               40.08***
                      (19.84)  
    ----------------------------
    Observations           74  
    R-squared           0.653  
    AIC                 396.5  
    F               66.785***  
    ----------------------------
    t statistics in parentheses
    * p<0.05, ** p<0.01, *** p<0.001

    Comment


    • #3
      Originally posted by Andrew Musau View Post
      estout is from SSC (FAQ Advice #12). If the P value is less than 0.001, then you will have a lot of "0.000" values in the P value row. It's just better to star the statistic, same as the coefficients. regress does not store the P value corresponding to the model's F-statistic, so you can use testparm to retrieve it. Here is an example that stars the F-statistic.

      Code:
      sysuse auto, clear
      eststo m1: regress mpg weight disp
      testparm *
      
      estadd local Fstat = cond(r(p)<0.01,"`:di %5.3f `=e(F)''***", ///
      cond(r(p)<0.05,"`:di %5.3f `=e(F)''**", ///
      cond(r(p)<0.1,"`:di %5.3f `=e(F)''*", "`:di %5.3f `=e(F)'''")))
      
      esttab m1, stats(N r2 aic Fstat, labels(Observations R-squared AIC F))
      Res.:

      Code:
      . esttab m1, stats(N r2 aic Fstat, labels(Observations R-squared AIC F))
      
      ----------------------------
      (1)
      mpg
      ----------------------------
      weight -0.00657***
      (-5.63)
      
      displacement 0.00528
      (0.54)
      
      _cons 40.08***
      (19.84)
      ----------------------------
      Observations 74
      R-squared 0.653
      AIC 396.5
      F 66.785***
      ----------------------------
      t statistics in parentheses
      * p<0.05, ** p<0.01, *** p<0.001

      Awesome! truly appreciate the effort, thanks!
      And how could I now add log likelihood to that?

      Comment


      • #4
        Code:
        esttab m1, stats(N r2 aic Fstat ll, labels(Observations R-squared AIC F Log-likelihood))

        Comment


        • #5
          Originally posted by Andrew Musau View Post
          Code:
          esttab m1, stats(N r2 aic Fstat ll, labels(Observations R-squared AIC F Log-likelihood))
          Hi Andrew,
          I still need your help: See image (is the code I have at the moment)
          Click image for larger version

Name:	Screenshot 2021-06-10 at 21.29.45.png
Views:	1
Size:	181.9 KB
ID:	1614172


          I tried to visualise the issue in the image below:

          Click image for larger version

Name:	Screenshot 2021-06-10 at 21.32.39.png
Views:	1
Size:	251.0 KB
ID:	1614173



          Only R squared is correct
          AIC continues (also for the regression models for which it doesnt apply)
          F statistic doesnt show for logit (which is good) but also only shows 1x for 1 model, whereas there are a lot more empty fields wr it should show.
          Loglikelihood shows everywere (but it should only show for logit)

          Could you please help me with this issue, rather urgent

          Comment


          • #6
            AIC continues (also for the regression models for which it doesnt apply)
            Loglikelihood shows everywere (but it should only show for logit)
            Not so. Linear models can also be estimated using maximum likelihood, so you can compute a log-likelihood and AIC. Here is an example:

            Code:
            sysuse auto, clear
            regress mpg weight disp i.rep78
            glm mpg weight disp i.rep78
            Res.:

            Code:
            . regress mpg weight disp i.rep78
            
                  Source |       SS           df       MS      Number of obs   =        69
            -------------+----------------------------------   F(6, 62)        =     21.30
                   Model |  1575.69146         6  262.615243   Prob > F        =    0.0000
                Residual |   764.51144        62  12.3308297   R-squared       =    0.6733
            -------------+----------------------------------   Adj R-squared   =    0.6417
                   Total |   2340.2029        68  34.4147485   Root MSE        =    3.5115
            
            ------------------------------------------------------------------------------
                     mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                  weight |  -.0062559   .0014844    -4.21   0.000    -.0092232   -.0032886
            displacement |   .0071103   .0128045     0.56   0.581    -.0184855    .0327061
                         |
                   rep78 |
                      2  |  -.6519631   2.797811    -0.23   0.817    -6.244708    4.940782
                      3  |  -.5992772   2.577557    -0.23   0.817    -5.751741    4.553187
                      4  |  -.6856857   2.625668    -0.26   0.795    -5.934321     4.56295
                      5  |   2.069259    2.74007     0.76   0.453    -3.408062    7.546581
                         |
                   _cons |   39.03528   3.572599    10.93   0.000     31.89375     46.1768
            ------------------------------------------------------------------------------
            
            . 
            . glm mpg weight disp i.rep78
            
            Iteration 0:   log likelihood = -180.88376  
            
            Generalized linear models                         Number of obs   =         69
            Optimization     : ML                             Residual df     =         62
                                                              Scale parameter =   12.33083
            Deviance         =  764.5114402                   (1/df) Deviance =   12.33083
            Pearson          =  764.5114402                   (1/df) Pearson  =   12.33083
            
            Variance function: V(u) = 1                       [Gaussian]
            Link function    : g(u) = u                       [Identity]
            
                                                              AIC             =   5.445906
            Log likelihood   = -180.8837605                   BIC             =   501.9968
            
            ------------------------------------------------------------------------------
                         |                 OIM
                     mpg |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                  weight |  -.0062559   .0014844    -4.21   0.000    -.0091653   -.0033465
            displacement |   .0071103   .0128045     0.56   0.579     -.017986    .0322066
                         |
                   rep78 |
                      2  |  -.6519631   2.797811    -0.23   0.816    -6.135572    4.831646
                      3  |  -.5992772   2.577557    -0.23   0.816    -5.651197    4.452643
                      4  |  -.6856857   2.625668    -0.26   0.794      -5.8319    4.460529
                      5  |   2.069259    2.74007     0.76   0.450    -3.301179    7.439697
                         |
                   _cons |   39.03528   3.572599    10.93   0.000     32.03311    46.03744
            ------------------------------------------------------------------------------
            
            .
            F statistic doesnt show for logit (which is good) but also only shows 1x for 1 model, whereas there are a lot more empty fields wr it should show.
            logit reports a likelihood ratio (LR) chi-square test statistic. So you should run the code that I show in #2 only after estimating a linear model. Why it does not display in your results, I cannot comment without a reproducible example.

            Comment

            Working...
            X