Announcement

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

  • interaction coefficients not showing in esttab

    I am conducting research to examine how the tone of a post on a social network site (e.g., how funny it is) and the social characteristics of the poster and a commenter predict the tone of a comment responding to the original post. I am using esttab to create a combined table to compare several regression tables. The esttab command correctly displays the t-test and stars for the regression with inteactions, but leaves the interaction coefficients blank.

    Here are the origina regression commands and the esttab comment
    Code:
    eststo test_betareg_nc:  reg hcomment_funny   c.post_dv  
    
    eststo test_betareg:  reg hcomment_funny   c.post_dv c.post_dv#(i.poster_gender i.commenter_gender i.poster_gender#commenter_gender)
    
    esttab  test_betareg_nc test_betareg using human_nonsupport.html,  wide star noomitted nobase label beta(%4.2f) staraux  r2(%4.2f) pr2(%4.2f) ar2(%4.2f)  bic(3) replace
    The output of the regression that included post X gender interaction show coefficients for all the interactions.
    Code:
    
    . eststo test_betareg:  reg hcomment_funny   c.post_dv c.post_dv#(i.poster_gender    i.commenter_gender i.poster_gender#commenter_gender)
    
    Source        SS           df       MS      Number of obs   =    10,000
    F(4, 9995)      =    613.66
    Model    68.518336         4   17.129584   Prob > F        =    0.0000
    Residual   278.998173     9,995  .027913774   R-squared       =    0.1972
    Adj R-squared   =    0.1968
    Total   347.516509     9,999  .034755126   Root MSE        =    .16707
    
        
    hcomment_funny  Coefficient  Std. err.      t    P>t    [95% conf. interval]
        
    post_dv    .4915041   .0121793    40.36   0.000    .4676303    .5153779
    
    poster_gender#c.post_dv
    p_male    -.0256989   .0221146    -1.16   0.245    -.069048    .0176501
    
    commenter_gender#c.post_dv
    c_male    -.1113106   .0257975    -4.31   0.000    -.161879   -.0607423
    
    poster_gender#commenter_gender#c.post_dv
    p_male#c_male     .1093427   .0365009     3.00   0.003    .0377936    .1808917
    
    _cons    .0658398   .0020153    32.67   0.000    .0618893    .0697902
        
    However the output of esttab, which includes the regression with interaction, doesn't show the coefficients for the interactions. Coefficients for main effects and t-tests for the interactions do show.
    Code:
    . esttab  test_betareg_nc test_betareg ,  wide star noomitted nobase label beta(%4.2f) staraux  r2(%4.2f) pr2(%4.2f) ar2(%4.2f)  bic(3) replace
    
    ------------------------------------------------------------------------------
                                  (1)                          (2)                
                              c_funny                      c_funny                
    ------------------------------------------------------------------------------
    post_dv                      0.44      (49.32)***         0.46      (40.36)***
    p_male # post_dv                                                    (-1.16)  
    c_male # post_dv                                                    (-4.31)***
    p_male # c_male # ~v                                                 (3.00)**
    ------------------------------------------------------------------------------
    Observations                10000                        10000                
    R-squared                    0.20                         0.20                
    Adjusted R-squared           0.20                         0.20                
    Pseudo R-squared                                                              
    BIC                     -7375.387                    -7366.529                
    ------------------------------------------------------------------------------
    Standardized beta coefficients; t statistics in parentheses
    * p<0.05, ** p<0.01, *** p<0.001

  • #2
    First, reinstall estout (from SSC) and try again. If the problem persists, present a data example that reproduces the issue.

    Code:
    ssc install estout, replace

    Comment


    • #3
      I updated estout, but the problem still exists. FYI, I am using Stata 18. Here is a data sample
      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input float(hcomment_funny post_dv) byte(poster_gender commenter_gender)
       .05496457  .15049894 1 1
      .002909103  .00589853 2 1
         .528337  .05458414 2 1
       .01538364  .25737134 2 2
        .3153635  .04562327 1 1
       .06378967  .10917323 1 2
      .030326286 .012917693 2 1
        .0246362  .04637615 2 2
       .50860435 .020040244 1 1
      .009974695 .018522233 1 1
      end
      label values poster_gender pgender_lbl
      label def pgender_lbl 1 "p_female", modify
      label def pgender_lbl 2 "p_male", modify
      label values commenter_gender cgender_lbl
      label def cgender_lbl 1 "c_female", modify
      label def cgender_lbl 2 "c_male", modify
      Last edited by robertekraut; 04 Jun 2024, 08:38.

      Comment


      • #4
        FYI, the problem seems to be in esttab, since estout prints the interaction coefficients;
        Code:
        . estout    test_betareg_nc test_betareg    ,    cells("b(fmt(3))    t(fmt(2))") noomitted    nobaselevels    label    unstack    replace
                       
            test_betar~c        test_betareg                
            b        t            b    t
                        
        post_dv    0.469        49.32        0.492    40.36
        p_male #    post_dv        -0.026    -1.16
        c_male #    post_dv        -0.111    -4.31
        p_male #    c_male # ~v        0.109    3.00
        _cons    0.066        32.68        0.066    32.67

        Comment


        • #5
          Here is an example demonstrating Robert's problem with publicly available data. A simple esttab statement does show the coefficient. It seems to be the beta option for standardized coefficients which makes it disappear.

          Code:
          sysuse auto, clear
          
          eststo test1: reg price foreign c.mpg
          eststo test2: reg price foreign c.mpg c.mpg#foreign
          
          esttab test1 test2, noomitted
          esttab test1 test2, noomitted beta(%4.2f)
          esttab test1 test2,  wide star noomitted nobase label beta(%4.2f) staraux  r2(%4.2f) pr2(%4.2f) ar2(%4.2f)  bic(3)
          Devra Golbe
          Professor Emerita, Dept. of Economics
          Hunter College, CUNY

          Comment


          • #6
            Devra, Thanks so much for isolating the problem. Yes, the problem goes away if I ask for regular coefficients rather than standardized one. The first code snippet works, but the second does not. Given my research goals, I can live without standardized coefficients.

            Code:
             
             [1] esttab  test_betareg_nc test_betareg ,  wide star noomitted nobase label b(%4.2f) staraux  r2(%4.2f) pr2(%4.2f) ar2(%4.2f)  bic(3) replace
            Code:
              [2]  esttab  test_betareg_nc test_betareg ,  wide star noomitted nobase label beta(%4.2f) staraux  r2(%4.2f) pr2(%4.2f) ar2(%4.2f)  bic(3) replace

            Comment


            • #7
              This is a bug with estout when outputting standardized (beta) coefficients, as Devra notes. It came up in an old thread which I will link once I am able to trace it. Use the -beta- option of regress and then replace the coefficients' matrix. Note that if you are reporting standardized coefficients, then there is no coefficient on the intercept term. I use erepost from SSC below.

              Code:
              ssc install erepost, replace
              Code:
              * Example generated by -dataex-. For more info, type help dataex
              clear
              input float(hcomment_funny post_dv) byte(poster_gender commenter_gender)
               .05496457  .15049894 1 1
              .002909103  .00589853 2 1
                 .528337  .05458414 2 1
               .01538364  .25737134 2 2
                .3153635  .04562327 1 1
               .06378967  .10917323 1 2
              .030326286 .012917693 2 1
                .0246362  .04637615 2 2
               .50860435 .020040244 1 1
              .009974695 .018522233 1 1
              end
              label values poster_gender pgender_lbl
              label def pgender_lbl 1 "p_female", modify
              label def pgender_lbl 2 "p_male", modify
              label values commenter_gender cgender_lbl
              label def cgender_lbl 1 "c_female", modify
              label def cgender_lbl 2 "c_male", modify
              
              reg hcomment_funny   c.post_dv, beta
              mat b= e(beta), `=_b[_cons]'
              mat colnames b= `:colnames e(b)'
              erepost b= b, rename
              est sto test_betareg_nc
              
              reg hcomment_funny   c.post_dv c.post_dv#(i.poster_gender i.commenter_gender i.poster_gender#commenter_gender), beta
              mat b= e(beta), `=_b[_cons]'
              mat colnames b= `:colnames e(b)'
              erepost b= b, rename
              est sto test_betareg
              
              esttab  test_betareg_nc test_betareg,  drop(_cons) wide star noomitted nobase label b(%4.2f) staraux  r2(%4.2f) pr2(%4.2f) ar2(%4.2f)  bic(3) replace

              Res.:

              Code:
              . esttab  test_betareg_nc test_betareg,  drop(_cons) wide star noomitted nobase label b(%4.2f) staraux  r2(%4.2f) pr2(%4.2f)
              >  ar2(%4.2f)  bic(3) replace
              
              ------------------------------------------------------------------------------
                                            (1)                          (2)                
                                   hcomment_f~y                 hcomment_f~y                
              ------------------------------------------------------------------------------
              post_dv                     -0.25      (-0.27)            0.04       (0.02)  
              p_male # post_dv                                          2.30       (0.50)  
              c_male # post_dv                                         -0.28      (-0.11)  
              p_male # c_male # ~v                                     -2.30      (-0.43)  
              ------------------------------------------------------------------------------
              Observations                   10                           10                
              R-squared                    0.06                         0.34                
              Adjusted R-squared          -0.06                        -0.19                
              Pseudo R-squared                                                              
              BIC                         0.274                        3.665                
              ------------------------------------------------------------------------------
              t statistics in parentheses
              * p<0.05, ** p<0.01, *** p<0.001
              
              .

              Comment


              • #8
                Andrew: is this-- in particular, post #4-- the thread you had in mind?
                Devra Golbe
                Professor Emerita, Dept. of Economics
                Hunter College, CUNY

                Comment


                • #9
                  Devra Golbe, thanks - your linked thread does illustrate the issue. This is the thread I had in mind: https://www.statalist.org/forums/for...c-coefficients

                  Comment


                  • #10
                    Thinking more about this problem, the workaround in #7 is not needed. regress in versions 17+ leaves behind a matrix of standardized coefficients with the -beta- option. You can refer to this matrix directly with esttab. Also, the t-statistics are not correct in #7.

                    Code:
                    * Example generated by -dataex-. For more info, type help dataex
                    clear
                    input float(hcomment_funny post_dv) byte(poster_gender commenter_gender)
                     .05496457  .15049894 1 1
                    .002909103  .00589853 2 1
                       .528337  .05458414 2 1
                     .01538364  .25737134 2 2
                      .3153635  .04562327 1 1
                     .06378967  .10917323 1 2
                    .030326286 .012917693 2 1
                      .0246362  .04637615 2 2
                     .50860435 .020040244 1 1
                    .009974695 .018522233 1 1
                    end
                    label values poster_gender pgender_lbl
                    label def pgender_lbl 1 "p_female", modify
                    label def pgender_lbl 2 "p_male", modify
                    label values commenter_gender cgender_lbl
                    label def cgender_lbl 1 "c_female", modify
                    label def cgender_lbl 2 "c_male", modify
                    
                    eststo test_betareg_nc: reg hcomment_funny   c.post_dv, beta
                    eststo test_betareg: reg hcomment_funny   c.post_dv c.post_dv#(i.poster_gender i.commenter_gender i.poster_gender#commenter_gender), beta
                    esttab  test_betareg_nc test_betareg,  drop(_cons) wide star noomitted nobase label main(beta %4.2f) staraux  r2(%4.2f) pr2(%4.2f) ar2(%4.2f)  bic(3) replace
                    Res.:

                    Code:
                    . esttab  test_betareg_nc test_betareg,  drop(_cons) wide star noomitted nobase label main(beta %4.2f) staraux  r2(%4.2f) pr
                    > 2(%4.2f) ar2(%4.2f)  bic(3) replace
                    
                    ------------------------------------------------------------------------------
                                                  (1)                          (2)                
                                         hcomment_f~y                 hcomment_f~y                
                    ------------------------------------------------------------------------------
                    post_dv                     -0.25      (-0.73)            0.04       (0.06)  
                    p_male # post_dv                                          2.30       (1.32)  
                    c_male # post_dv                                         -0.28      (-0.28)  
                    p_male # c_male # ~v                                     -2.30      (-1.12)  
                    ------------------------------------------------------------------------------
                    Observations                   10                           10                
                    R-squared                    0.06                         0.34                
                    Adjusted R-squared          -0.06                        -0.19                
                    Pseudo R-squared                                                              
                    BIC                         0.274                        3.665                
                    ------------------------------------------------------------------------------
                    beta coefficients; t statistics in parentheses
                    * p<0.05, ** p<0.01, *** p<0.001
                    Last edited by Andrew Musau; 05 Jun 2024, 02:21.

                    Comment


                    • #11
                      Dear all, has this problem been solved recently?

                      Comment

                      Working...
                      X