Announcement

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

  • #16
    Thanks Carlo. How exactly would I use -test- and -lincom- in this case?

    Comment


    • #17
      Ashani:
      I do hope the following toy-example is useful:
      Code:
      . use "https://www.stata-press.com/data/r18/nlswork.dta"
      (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
      
      . xtreg ln_wage i.race##i.union c.age##c.age, fe vce(cluster idcode)
      note: 2.race omitted because of collinearity.
      note: 3.race omitted because of collinearity.
      
      Fixed-effects (within) regression               Number of obs     =     19,229
      Group variable: idcode                          Number of groups  =      4,150
      
      R-squared:                                      Obs per group:
           Within  = 0.0986                                         min =          1
           Between = 0.0451                                         avg =        4.6
           Overall = 0.0576                                         max =         12
      
                                                      F(5, 4149)        =     137.88
      corr(u_i, Xb) = 0.0133                          Prob > F          =     0.0000
      
                                   (Std. err. adjusted for 4,150 clusters in idcode)
      ------------------------------------------------------------------------------
                   |               Robust
           ln_wage | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
      -------------+----------------------------------------------------------------
              race |
            Black  |          0  (omitted)
            Other  |          0  (omitted)
                   |
           1.union |   .1103597    .012985     8.50   0.000     .0849021    .1358173
                   |
        race#union |
          Black#1  |  -.0073757   .0195842    -0.38   0.706    -.0457713    .0310198
          Other#1  |  -.3047801   .1156961    -2.63   0.008    -.5316064   -.0779537
                   |
               age |   .0323436   .0051042     6.34   0.000     .0223367    .0423506
                   |
       c.age#c.age |  -.0002734   .0000817    -3.35   0.001    -.0004337   -.0001132
                   |
             _cons |   .9950981   .0782405    12.72   0.000     .8417048    1.148492
      -------------+----------------------------------------------------------------
           sigma_u |  .42313891
           sigma_e |  .26182965
               rho |  .72312438   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      
      . mat list e(b)
      
      e(b)[1,14]
                  1b.         2o.         3o.         0b.          1.    1b.race#    1b.race#    2o.race#     2.race#    3o.race#     3.race#                  c.age#
                race        race        race       union       union    0b.union    1o.union    0b.union     1.union    0b.union     1.union         age       c.age
      y1           0           0           0           0   .11035969           0           0           0  -.00737575           0   -.3047801   .03234362  -.00027342
      
                     
               _cons
      y1   .99509814
      
      . test 2.race#1.union=3.race#1.union
      
       ( 1)  2.race#1.union - 3.race#1.union = 0
      
             F(  1,  4149) =    6.58
                  Prob > F =    0.0103
      
      . testparm i.race##i.union
      
       ( 1)  1.union = 0
       ( 2)  2.race#1.union = 0
       ( 3)  3.race#1.union = 0
      
             F(  3,  4149) =   41.33
                  Prob > F =    0.0000
      
      . help lincom
      
      . lincom 1.union - 0b.union
      
       ( 1)  - 0b.union + 1.union = 0
      
      ------------------------------------------------------------------------------
           ln_wage | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
      -------------+----------------------------------------------------------------
               (1) |   .1103597    .012985     8.50   0.000     .0849021    .1358173
      ------------------------------------------------------------------------------
      
      .
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #18
        Hi Carlo,

        Thank you very much for the illustration which is very helpful. In my case, to test for differences in the effect of unemployment and staff firing by mental health status, would the following code work (which indicates that there is a marginally significant difference in terms of the unemployment effect, but not for staff firing)?

        Code:
        xtreg jobsec mh9_q1##( c.unemp c.fire1) i.j1, fe i(id) cluster(id)
        
        Fixed-effects (within) regression               Number of obs     =     48,024
        Group variable: id                              Number of groups  =      6,003
        
        R-squared:                                      Obs per group:
             Within  = 0.2570                                         min =          8
             Between = 0.0188                                         avg =        8.0
             Overall = 0.1829                                         max =          8
        
                                                        F(15,6002)        =     576.94
        corr(u_i, Xb) = -0.0213                         Prob > F          =     0.0000
        
                                           (Std. err. adjusted for 6,003 clusters in id)
        --------------------------------------------------------------------------------
                       |               Robust
                jobsec | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
        ---------------+----------------------------------------------------------------
              1.mh9_q1 |          0  (omitted)
                 unemp |  -.1211826    .003892   -31.14   0.000    -.1288124   -.1135529
                 fire1 |  -.1585208   .0020321   -78.01   0.000    -.1625044   -.1545372
                       |
        mh9_q1#c.unemp |
                    1  |   .0164109   .0090537     1.81   0.070    -.0013377    .0341594
                       |
        mh9_q1#c.fire1 |
                    1  |   .0064037   .0043519     1.47   0.141    -.0021276     .014935
                       |
                    j1 |
                    2  |  -.0108441   .0408108    -0.27   0.790    -.0908479    .0691598
                    3  |  -.0382829    .041024    -0.93   0.351    -.1187047    .0421388
                    4  |  -.0483699   .0409416    -1.18   0.237    -.1286301    .0318904
                    5  |   .0057767   .0415139     0.14   0.889    -.0756055    .0871589
                    6  |  -.0189513   .0409312    -0.46   0.643    -.0991912    .0612887
                    7  |   .0492266   .0409829     1.20   0.230    -.0311146    .1295678
                    8  |   .0070104   .0408559     0.17   0.864    -.0730819    .0871027
                    9  |  -.0415234   .0415246    -1.00   0.317    -.1229267    .0398798
                   10  |   .0093576   .0406655     0.23   0.818    -.0703614    .0890765
                   11  |   -.025912   .0403782    -0.64   0.521    -.1050678    .0532437
                   12  |    -.02021   .0411519    -0.49   0.623    -.1008825    .0604625
                       |
                 _cons |   6.656268   .0291539   228.32   0.000     6.599116     6.71342
        ---------------+----------------------------------------------------------------
               sigma_u |  1.2659379
               sigma_e |  1.7768792
                   rho |   .3366876   (fraction of variance due to u_i)
        --------------------------------------------------------------------------------
        
        test 0b.mh9_q1#co.unemp=1.mh9_q1#c.unemp
        
         ( 1)  0b.mh9_q1#co.unemp - 1.mh9_q1#c.unemp = 0
        
               F(  1,  6002) =    3.29
                    Prob > F =    0.0699
        
        
        test 0b.mh9_q1#co.fire1=1.mh9_q1#c.fire1
        
         ( 1)  0b.mh9_q1#co.fire1 - 1.mh9_q1#c.fire1 = 0
        
               F(  1,  6002) =    2.17
                    Prob > F =    0.1412
        I also have a follow-up question. Since the mental health variable does not change across the different evaluations for a given person, it is omitted in the fixed-effects regression. If I remove the fixed-effects specification (and presumably estimate a random-effects model), the mental health indicator variable is retained and the results are somewhat different. How do I decide which model is better?

        Thank you very much.

        Comment


        • #19
          Alternatively, could I test for the difference as follows?

          Code:
          lincom 0b.mh9_q1#co.unemp-1.mh9_q1#c.unemp
          
           ( 1)  0b.mh9_q1#co.unemp - 1.mh9_q1#c.unemp = 0
          
          ------------------------------------------------------------------------------
                jobsec | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
          -------------+----------------------------------------------------------------
                   (1) |  -.0164109   .0090537    -1.81   0.070    -.0341594    .0013377
          ------------------------------------------------------------------------------

          Comment


          • #20
            Ashani:
            1) choosing which one of the two specifications is -fe- or -re- is better for your research (see Changing effect directions in fixed-effects estimation compared to OLS. - Statalist);
            2) if you're interested in the coefficient of a time-invariant predictor you may want to consider Mundlak;
            3) yes, you can also go -lincom-.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #21
              Hi all,

              Related to #14 above, what I have done so far is to run:

              Code:
              xtreg jobsec mh9_q1##( c.unemp male1 c.age c.tenure contract c.fire1 c.hire1) i.j1, cluster(id)
              and then test whether the 'unemp' coefficients for mh9_qn1=0 and mh9_qn1=1 are statistically different, using:

              Code:
              lincom 0b.mh8_qn1#co.unemp_av6-1.mh8_qn1#c.unemp_av6
              I now want to conduct a one-tailed test, to specifically test whether the unemp coefficient is significantly more negative for those in good mental health (mh9_qn1=0). How would I do this?

              Many thanks in advance.

              Comment

              Working...
              X