Announcement

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

  • #46
    I've never used this method, so I learned something. As usual, JW makes what appears to be messy easy to do.

    Comment


    • #47
      Prof Ford, I really appreciate the explanation. In line with WP Paper, I can make an argument on whether to make a higher level aggregation or not. right? Because the primary question on the table is that.
      Code:
       xtset id year
             panel variable:  id (unbalanced)
              time variable:  year, 2010 to 2019, but with gaps
                      delta:  1 unit
      
      
      bysort id: egen mean__immi_sh = mean(immi_sh)
      bysort id: egen mean__share_9 = mean( share_9)
      bysort id: egen mean__share_12= mean(share_uni)
      bysort id: egen mean__share_uni = mean(logsize)
      bysort id: egen mean__logsize = mean(lavg_firm_age)
      bysort id: egen mean__lavg_firm_age= mean(lavg_firm_age)
      bysort id: egen mean__lage  = mean(lage)
      bysort id: egen mean__year = mean(year)
      
      . reghdfe ln_labor_productivity immi_sh share_9 share_12 share_uni  logsize         ///
      >     lavg_firm_age lage i.year mean__immi_sh mean__share_9              ///
      >     mean__share_12 mean__share_uni  mean__logsize  mean__lavg_firm_age             ///
      >     mean__lage mean__year, absorb(sector region sector#region)                     ///
      >     cluster(sector)
      (MWFE estimator converged in 2 iterations)
      note: mean__lavg_firm_age omitted because of collinearity
      warning: missing F statistic; dropped variables due to collinearity or too few clusters
      
      HDFE Linear regression                            Number of obs   =  1,514,590
      Absorbing 3 HDFE groups                           F(  23,      7) =          .
      Statistics robust to heteroskedasticity           Prob > F        =          .
                                                        R-squared       =     0.1674
                                                        Adj R-squared   =     0.1674
                                                        Within R-sq.    =     0.1042
      Number of clusters (sector)  =          8         Root MSE        =     0.8433
      
                                              (Std. Err. adjusted for 8 clusters in sector)
      -------------------------------------------------------------------------------------
                          |               Robust
      ln_labor_producti~y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      --------------------+----------------------------------------------------------------
                  immi_sh |   .0044312   .0221644     0.20   0.847    -.0479793    .0568417
                  share_9 |   .3233302   .0464193     6.97   0.000     .2135661    .4330943
                 share_12 |   .4447063   .0594037     7.49   0.000     .3042389    .5851737
                share_uni |   .3898605   .0667516     5.84   0.001      .232018    .5477029
                  logsize |  -.0530656     .01664    -3.19   0.015     -.092413   -.0137182
            lavg_firm_age |     .06839   .0084707     8.07   0.000       .04836    .0884201
                     lage |   .0941849   .0294198     3.20   0.015     .0246181    .1637516
                          |
                     year |
                    2011  |  -.0545539   .0142667    -3.82   0.007    -.0882892   -.0208186
                    2012  |  -.0865313   .0470727    -1.84   0.109    -.1978407     .024778
                    2013  |  -.0558563   .0577864    -0.97   0.366    -.1924995    .0807869
                    2014  |  -.0680847   .0629978    -1.08   0.316    -.2170508    .0808813
                    2015  |  -.0686263   .0657259    -1.04   0.331    -.2240434    .0867909
                    2016  |  -.0680697   .0654029    -1.04   0.333    -.2227231    .0865837
                    2017  |  -.0835982   .0604586    -1.38   0.209      -.22656    .0593636
                    2018  |  -.1137503   .0533071    -2.13   0.070    -.2398016    .0123011
                    2019  |  -.1378348   .0481916    -2.86   0.024    -.2517898   -.0238798
                          |
            mean__immi_sh |  -.1179342   .0671146    -1.76   0.122    -.2766349    .0407665
            mean__share_9 |  -.1481924   .0250892    -5.91   0.001    -.2075189   -.0888659
           mean__share_12 |   .4651646   .1342867     3.46   0.010      .147627    .7827023
          mean__share_uni |   .2473019   .0443147     5.58   0.001     .1425142    .3520896
            mean__logsize |   .0293096   .0141171     2.08   0.077     -.004072    .0626912
      mean__lavg_firm_age |          0  (omitted)
               mean__lage |     .00315   .0883127     0.04   0.973    -.2056764    .2119763
               mean__year |    .064638   .0066379     9.74   0.000     .0489419    .0803342
                    _cons |  -121.7594   13.44116    -9.06   0.000    -153.5427    -89.9761
      -------------------------------------------------------------------------------------
      
      Absorbed degrees of freedom:
      ---------------------------------------------------------+
           Absorbed FE | Categories  - Redundant  = Num. Coefs |
      -----------------+---------------------------------------|
                sector |         8           8           0    *|
                region |         8           1           7     |
         sector#region |        60          60           0    *|
      ---------------------------------------------------------+
      * = FE nested within cluster; treated as redundant for DoF computation
      
      .
      . test mean__immi_sh mean__share_9  mean__share_12 mean__share_uni                  ///
      >     mean__logsize mean__lavg_firm_age mean__lage mean__year
      
       ( 1)  mean__immi_sh = 0
       ( 2)  mean__share_9 = 0
       ( 3)  mean__share_12 = 0
       ( 4)  mean__share_uni = 0
       ( 5)  mean__logsize = 0
       ( 6)  o.mean__lavg_firm_age = 0
       ( 7)  mean__lage = 0
       ( 8)  mean__year = 0
             Constraint 6 dropped
      
             F(  7,     7) =  749.42
                  Prob > F =    0.0000
      
      .
      The second code"
      Code:
      .  reghdfe ln_labor_productivity immi_sh share_9 share_12 share_uni  logsize        ///    
      > avg_firm_age lage  mean__immi_sh mean__share_9                       ///    
      > mean__share_12 mean__share_uni  mean__logsize  mean__lavg_firm_age        ///
      >     mean__lage , absorb(sector region sector#region year)   cluster(sector)  
      (MWFE estimator converged in 4 iterations)
      note: mean__lavg_firm_age omitted because of collinearity
      warning: missing F statistic; dropped variables due to collinearity or too few clusters
      
      HDFE Linear regression                            Number of obs   =  1,562,462
      Absorbing 4 HDFE groups                           F(  13,      7) =          .
      Statistics robust to heteroskedasticity           Prob > F        =          .
                                                        R-squared       =     0.1674
                                                        Adj R-squared   =     0.1674
                                                        Within R-sq.    =     0.1036
      Number of clusters (sector)  =          8         Root MSE        =     0.8559
      
                                              (Std. Err. adjusted for 8 clusters in sector)
      -------------------------------------------------------------------------------------
                          |               Robust
      ln_labor_producti~y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      --------------------+----------------------------------------------------------------
                  immi_sh |  -.0022622   .0240769    -0.09   0.928    -.0591951    .0546706
                  share_9 |   .3240873    .047084     6.88   0.000     .2127514    .4354232
                 share_12 |    .431022    .058403     7.38   0.000     .2929209    .5691232
                share_uni |   .3424674   .0681693     5.02   0.002     .1812726    .5036622
                  logsize |  -.0216342   .0170088    -1.27   0.244    -.0618537    .0185853
             avg_firm_age |  -.0095091   .0023529    -4.04   0.005    -.0150729   -.0039454
                     lage |   .0313209   .0230397     1.36   0.216    -.0231593    .0858011
            mean__immi_sh |  -.1073892   .0644239    -1.67   0.139    -.2597275     .044949
            mean__share_9 |  -.1657764   .0282882    -5.86   0.001    -.2326673   -.0988854
           mean__share_12 |   .5061827   .1441416     3.51   0.010     .1653421    .8470234
          mean__share_uni |   .2200251   .0438413     5.02   0.002      .116357    .3236932
            mean__logsize |   .2093602     .02306     9.08   0.000     .1548319    .2638885
      mean__lavg_firm_age |          0  (omitted)
               mean__lage |   .1150118   .0883542     1.30   0.234    -.0939127    .3239364
                    _cons |   8.081939   .3525108    22.93   0.000     7.248384    8.915495
      -------------------------------------------------------------------------------------
      
      Absorbed degrees of freedom:
      ---------------------------------------------------------+
           Absorbed FE | Categories  - Redundant  = Num. Coefs |
      -----------------+---------------------------------------|
                sector |         8           8           0    *|
                region |         8           1           7     |
         sector#region |        60          60           0    *|
                  year |        10           1           9     |
      ---------------------------------------------------------+
      * = FE nested within cluster; treated as redundant for DoF computation
      
      .
      . test mean__immi_sh mean__share_9  mean__share_12 mean__share_uni         ///
      >     mean__logsize mean__lavg_firm_age mean__lage
      
       ( 1)  mean__immi_sh = 0
       ( 2)  mean__share_9 = 0
       ( 3)  mean__share_12 = 0
       ( 4)  mean__share_uni = 0
       ( 5)  mean__logsize = 0
       ( 6)  o.mean__lavg_firm_age = 0
       ( 7)  mean__lage = 0
             Constraint 6 dropped
      
             F(  6,     7) =   38.53
                  Prob > F =    0.0001
      Last edited by Paris Rira; 22 May 2024, 17:54.

      Comment


      • #48
        Nope. Your F of 38.53 is strongly rejected.

        Try it without sector#region in absorb, though I doubt much effect.

        Fix the error here. Same variable.
        Code:
        bysort id: egen mean__logsize = mean(lavg_firm_age)
        bysort id: egen mean__lavg_firm_age= mean(lavg_firm_age)

        Try this too. It will allow you to fiddle with your model without having to rewrite the PW Test each time.
        (Check it on the model you just ran (with errors) to make sure you get the same results: F = 38.53)
        Code:
        capture program drop papwood
        program papwood , rclass
        syntax [, altfe(varlist min=1 max=1)]
        preserve
        quietly {
        capture drop *_xxx
        global XTERMS
        global MTERMS
        local varnum =  wordcount(`"`e(indepvars)'"')-1
        forv i = 1/`varnum' {
            local var = `'"`: word `i' of `e(indepvars)''"'
            global XTERMS $XTERMS `var'
            egen `var'_xxx = mean(`var') , by(`altfe')
            global MTERMS $MTERMS `var'_xxx
        }
        reghdfe `e(depvar)' $XTERMS $MTERMS , absorb(`e(absvars)') cluster(`e(clustvar)')
        test $MTERMS
        }
        local star = (cond(r(p)<.01, "***", cond(r(p)<.05, "**", cond(r(p)<.10, "*", ""))))
        di `"{hline 50}"'
        di "Papke-Wooldridge (2023) Test"
        di "Null:  Higher level fixed effects is OK."
        di "F-stat = " %6.2f `r(F)' "`star'"
        di "Prob Level = " %8.6f r(p)
        if r(p) < 0.10 {
            di "Null is REJECTED -- Yuck!"
        }
        else {
            di "Null is ACCEPTED -- Yeah!"
        }
        di `"{hline 50}"'
        restore
        end
        Code:
        reghdfe ln_labor_productivity immi_sh share_9 share_12 share_uni logsize ///
             avg_firm_age lage , absorb(sector region sector#region year) cluster(sector)
        papwood, altfe(id)
        Last edited by George Ford; 22 May 2024, 19:15.

        Comment


        • #49
          If you want to see the augmented regression, put "nois" in front of the "reghdfe" command.

          Comment


          • #50
            You can also run the test just on the immi variable. Lots more code, but it's provided in the link JW provided.

            Comment


            • #51
              Code:
              . capture program drop papwood
              
              . program papwood , rclass
                1. syntax [, altfe(ln_labor_productivity immi_sh share_9 share_12 share_uni logsize avg_firm_age lage min=1 max=1)]
                2. preserve
                3. quietly {
                4. capture drop *_xxx
                5. global XTERMS
                6. global MTERMS
                7. local varnum =  wordcount(`"`e( immi_sh share_9 share_12 share_uni logsize avg_firm_age lage)'"')-1
                8. forv i = 1/`varnum' {
                9.     local var = `'"`: word `i' of `e( immi_sh share_9 share_12 share_uni logsize avg_firm_age lage)''"'
               10.     global XTERMS $XTERMS `var'
               11.     egen `var'_xxx = mean(`var') , by(`altfe')
               12.     global MTERMS $MTERMS `var'_xxx
               13. }
               14. reghdfe `e(ln_labor_productivity)' $XTERMS $MTERMS , absorb(`e(sector region sector#region year)') cluster(`e(sector)')
               15. test $MTERMS
               16. }
               17. local star = (cond(r(p)<.01, "***", cond(r(p)<.05, "**", cond(r(p)<.10, "*", ""))))
               18. di `"{hline 50}"'
               19. di "Papke-Wooldridge (2023) Test"
               20. di "Null:  Higher level fixed effects is OK."
               21. di "F-stat = " %6.2f `r(F)' "`star'"
               22. di "Prob Level = " %8.6f r(p)
               23. if r(p) < 0.10 {
               24.     di "Null is REJECTED"
               25. }
               26. else {
               27.     di "Null is ACCEPTED"
               28. }
               29. di `"{hline 50}"'
               30. restore
               31. end
              
              . 
              end of do-file
              
              . do "C:\Users\CeBER\AppData\Local\Temp\STD135c_000000.tmp"
              
              . reghdfe ln_labor_productivity immi_sh share_9 share_12 share_uni logsize ///
              >      avg_firm_age lage , absorb(sector region sector#region year) cluster(sector)
              (MWFE estimator converged in 4 iterations)
              
              HDFE Linear regression                            Number of obs   =  1,575,948
              Absorbing 4 HDFE groups                           F(   7,      7) =    8509.86
              Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                                R-squared       =     0.1499
                                                                Adj R-squared   =     0.1498
                                                                Within R-sq.    =     0.0850
              Number of clusters (sector)  =          8         Root MSE        =     0.8708
              
                                               (Std. Err. adjusted for 8 clusters in sector)
              ------------------------------------------------------------------------------
                           |               Robust
              ln_labor_p~y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                   immi_sh |  -.1399509   .0761987    -1.84   0.109    -.3201321    .0402304
                   share_9 |   .2012313   .0277511     7.25   0.000     .1356104    .2668523
                  share_12 |   .4459813   .0619086     7.20   0.000     .2995907     .592372
                 share_uni |    .800066   .1038243     7.71   0.000     .5545604    1.045572
                   logsize |   .1933575   .0336375     5.75   0.001     .1138174    .2728975
              avg_firm_age |   .0041543   .0016538     2.51   0.040     .0002438    .0080649
                      lage |   .2057504   .0696364     2.95   0.021     .0410865    .3704144
                     _cons |   8.119879   .2891404    28.08   0.000     7.436171    8.803588
              ------------------------------------------------------------------------------
              
              Absorbed degrees of freedom:
              ---------------------------------------------------------+
                   Absorbed FE | Categories  - Redundant  = Num. Coefs |
              -----------------+---------------------------------------|
                        sector |         8           8           0    *|
                        region |         8           1           7     |
                 sector#region |        60          60           0    *|
                          year |        10           1           9     |
              ---------------------------------------------------------+
              * = FE nested within cluster; treated as redundant for DoF computation
              
              . papwood, altfe(id)
              invalid syntax
              r(197);
              
              end of do-file
              
              r(197);
              What I missed ?

              Comment


              • #52
                Originally posted by George Ford View Post
                Nope. Your F of 38.53 is strongly rejected.
                "https://blog.stata.com/2015/10/29/fixed-effects-or-random-effects-the-mundlak-approach/"

                "If you reject that the coefficients are jointly zero, the test suggests that there is correlation between the time-invariant unobservables and your regressors, namely, the fixed-effects assumptions are satisfied."
                right? so my result reject the null hypo. does not ? I dont get it .

                Comment


                • #53
                  Don’t change anything in the papwood program. Leave it as I sent it.

                  You don’t want to reject the null.

                  and you can’t replicate the other result. My code creates new variables. The code does replicate exactly what was in JW’s code.

                  Comment


                  • #54
                    I ran after correcting the above error.
                    Code:
                    . capture program drop papwood
                    
                    . program papwood , rclass
                      1. syntax [, altfe(varlist min=1 max=1)]
                      2. preserve
                      3. quietly {
                      4. capture drop *_xxx
                      5. global XTERMS
                      6. global MTERMS
                      7. local varnum =  wordcount(`"`e(indepvars)'"')-1
                      8. forv i = 1/`varnum' {
                      9.     local var = `'"`: word `i' of `e(indepvars)''"'
                     10.     global XTERMS $XTERMS `var'
                     11.     egen `var'_xxx = mean(`var') , by(`altfe')
                     12.     global MTERMS $MTERMS `var'_xxx
                     13. }
                     14. reghdfe `e(depvar)' $XTERMS $MTERMS , absorb(`e(absvars)') cluster(`e(clustvar)')
                     15. test $MTERMS
                     16. }
                     17. local star = (cond(r(p)<.01, "***", cond(r(p)<.05, "**", cond(r(p)<.10, "*", ""))))
                     18. di `"{hline 50}"'
                     19. di "Papke-Wooldridge (2023) Test"
                     20. di "Null:  Higher level fixed effects is OK."
                     21. di "F-stat = " %6.2f `r(F)' "`star'"
                     22. di "Prob Level = " %8.6f r(p)
                     23. if r(p) < 0.10 {
                     24.     di "Null is REJECTED -- Yuck!"
                     25. }
                     26. else {
                     27.     di "Null is ACCEPTED -- Yeah!"
                     28. }
                     29. di `"{hline 50}"'
                     30. restore
                     31. end
                    
                    .
                    . nois reghdfe ln_labor_productivity immi_sh share_9 share_12 share_uni logsize ///
                    >      avg_firm_age lage , absorb(sector region sector#region year) cluster(sector)
                    (MWFE estimator converged in 4 iterations)
                    
                    HDFE Linear regression                            Number of obs   =  1,575,948
                    Absorbing 4 HDFE groups                           F(   7,      7) =    8509.86
                    Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                                      R-squared       =     0.1499
                                                                      Adj R-squared   =     0.1498
                                                                      Within R-sq.    =     0.0850
                    Number of clusters (sector)  =          8         Root MSE        =     0.8708
                    
                                                     (Std. Err. adjusted for 8 clusters in sector)
                    ------------------------------------------------------------------------------
                                 |               Robust
                    ln_labor_p~y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                    -------------+----------------------------------------------------------------
                         immi_sh |  -.1399509   .0761987    -1.84   0.109    -.3201321    .0402304
                         share_9 |   .2012313   .0277511     7.25   0.000     .1356104    .2668523
                        share_12 |   .4459813   .0619086     7.20   0.000     .2995907     .592372
                       share_uni |    .800066   .1038243     7.71   0.000     .5545604    1.045572
                         logsize |   .1933575   .0336375     5.75   0.001     .1138174    .2728975
                    avg_firm_age |   .0041543   .0016538     2.51   0.040     .0002438    .0080649
                            lage |   .2057504   .0696364     2.95   0.021     .0410865    .3704144
                           _cons |   8.119879   .2891404    28.08   0.000     7.436171    8.803588
                    ------------------------------------------------------------------------------
                    
                    Absorbed degrees of freedom:
                    ---------------------------------------------------------+
                         Absorbed FE | Categories  - Redundant  = Num. Coefs |
                    -----------------+---------------------------------------|
                              sector |         8           8           0    *|
                              region |         8           1           7     |
                       sector#region |        60          60           0    *|
                                year |        10           1           9     |
                    ---------------------------------------------------------+
                    * = FE nested within cluster; treated as redundant for DoF computation
                    
                    . papwood, altfe(id)
                    --------------------------------------------------
                    Papke-Wooldridge (2023) Test
                    Null:  Higher level fixed effects is OK.
                    F-stat =  85.75***
                    Prob Level = 0.000003
                    Null is REJECTED -- Yuck!
                    --------------------------------------------------
                    Last edited by Paris Rira; 22 May 2024, 20:42.

                    Comment


                    • #55
                      Not the result you were hoping for. sorry.

                      Comment


                      • #56
                        The question is that I have to drop region and sector fixed effects in favor of firm fixed effects. Since firms don't move across region and sectors, so I can't use three FEs simultaneously.

                        Comment


                        • #57
                          Also, I wonder if the size matters, I could not find in PW(2023) if they argue aggregate level size. I mean because of 1.5 million datasets and sectors are only 8. It can be the reason?

                          Comment


                          • #58
                            As I understand it, and I’ve only seen this work today, is that the hope is that you’ve got enough firm specific variables that there’s no consequence of firm level omitted variables to speak of, making the firm FE redundant. You don’t have that situation. You don’t need fewer firm variables, but more. But, as you add more, the result will look more like the firm FE result.

                            Fiddling is not going to save you. With 1.5m observations, it’s difficult not to get a statistically significant result. On top of that, clustering by sector (only 8 of them) is going to lead to SE that are too small, not too large. The odds are in your favor.

                            you’ll need to become more intimate with your data to figure out whether you’ve missed something interesting. Perhaps the effect is nonlinear? How much variation do you have in immig? How much does productivity vary within sector, and between regions? Did the data import and merge properly?

                            The effect may very well be zero. I’m fairly convinced it is. wanting it to be otherwise is immaterial. It is what it is.

                            At this point, for me, I’d take a few days off and hope some different way to think about this comes to mind. Read other papers on this and similar topics to see if there’s a different way to approach the problem. But understand that research doesn’t always work out as planned.




                            Comment


                            • #59
                              Dear Prof Ford,

                              I really appreciate your time and consideration for this thread. I have learned a lot from your guidance. As you mentioned, research is not always expected to have significant effects, and finding no effect is still valuable evidence as some other authors on this topic already reached the same results as mine. Among the models, the IV model produced significant results, which I can interpret properly.
                              I hope this thread will help other students in the future who may encounter the same issue.

                              I wonder if it would be possible to mention your name in my work?

                              Thank you once again for your help.

                              Cheers,

                              Paris

                              Comment


                              • #60
                                I learned something new as well.

                                i’d interact immig with sector. You’d think immig matters more to certain sectors.

                                or run the model sector by sector to see if the results differ much.

                                Comment

                                Working...
                                X