Announcement

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

  • #31
    Ketherine:
    yes, and it is assumed to be the same for each year for a given country (it's up to you to decide whether [or not] this assumption is reasonable).
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #32
      Clyde,

      I have a more fundamental question, to begin with. Using a panel data framework, how do we know what fixed effects to include? Is there a guiding principle to that? What I mean by this is that (in studying the effect of a random treatment on county-level outcomes), in some papers I see only time and county-fixed effects are included, while others include year, county, and year*state-fixed effects, some also include a linear time trend either separately or being interacted with the covariates. Hence, I am a bit confused. As far as I understand, fixed effects take care of unobserved heterogeneity which either vary with time or cross-sectional units.

      Other than this general question, I am trying to replicate the following regression in STATA ( i : county, s: state, t: year). It would be very helpful if you can tell me how I can approach this problem,

      y_{ist} = \beta_1 H_{it}^{1-5} + \beta_2 H_{it}^{6-10} + \alpha_i + \alpha_{st} + \delta' (X_i \alpha_t) + \epsilon_{ist}
      Last edited by Anupam Ghosh; 19 Sep 2024, 23:54.

      Comment


      • #33
        Anupam:
        the usual recipe is to include both -panelid- and -time- fixed effects.
        Basically, the -fe- estimator subtracts from any variables the within-panel mean.
        Therefore, for a time-invariant variable, no coefficient will be returned.
        This way, the -fe- estimator takes unobserved the time-invariant heterogeneity into account.
        As far as the time-varying unobserved heterogeneity is concerned, the -fe- estimator allows it to be correlated with the vector of regressors (a likited form of endogeneity).
        You may want to take a look at -xtset-, -xtreg,fe- and the community-contributed module -reghdfe-.
        Your regression equation is not readable: please use CODE delimiters (as per FAQ). Thanks.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #34
          Carlo,

          Thanks for responding. Is there a qualitative difference between using the i.year and absorb(year) fe options?

          Comment


          • #35
            Anupam:
            the main difference is that -reghdfe- gives you back the -year- fixed effect, too:
            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 c.age##c.age i.year, fe vce(cluster idcode)
            
            Fixed-effects (within) regression               Number of obs     =     28,510
            Group variable: idcode                          Number of groups  =      4,710
            
            R-squared:                                      Obs per group:
                 Within  = 0.1162                                         min =          1
                 Between = 0.1078                                         avg =        6.1
                 Overall = 0.0932                                         max =         15
            
                                                            F(16, 4709)       =      79.11
            corr(u_i, Xb) = 0.0613                          Prob > F          =     0.0000
            
                                         (Std. err. adjusted for 4,710 clusters in idcode)
            ------------------------------------------------------------------------------
                         |               Robust
                 ln_wage | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                     age |   .0728746    .013687     5.32   0.000     .0460416    .0997075
                         |
             c.age#c.age |  -.0010113   .0001076    -9.40   0.000    -.0012224   -.0008003
                         |
                    year |
                     69  |   .0647054   .0155249     4.17   0.000     .0342693    .0951415
                     70  |   .0284423   .0264639     1.07   0.283    -.0234395     .080324
                     71  |   .0579959   .0384111     1.51   0.131    -.0173078    .1332996
                     72  |   .0510671   .0502675     1.02   0.310    -.0474808     .149615
                     73  |   .0424104   .0624924     0.68   0.497    -.0801038    .1649247
                     75  |   .0151376    .086228     0.18   0.861    -.1539096    .1841848
                     77  |   .0340933   .1106841     0.31   0.758    -.1828994     .251086
                     78  |   .0537334   .1232232     0.44   0.663    -.1878417    .2953084
                     80  |   .0369475   .1473725     0.25   0.802    -.2519716    .3258667
                     82  |   .0391687   .1715621     0.23   0.819    -.2971733    .3755108
                     83  |    .058766   .1836086     0.32   0.749    -.3011928    .4187249
                     85  |   .1042758   .2080199     0.50   0.616    -.3035406    .5120922
                     87  |   .1242272   .2327328     0.53   0.594    -.3320379    .5804922
                     88  |   .1904977   .2486083     0.77   0.444    -.2968909    .6778863
                         |
                   _cons |   .3937532   .2469015     1.59   0.111    -.0902893    .8777957
            -------------+----------------------------------------------------------------
                 sigma_u |  .40275174
                 sigma_e |  .30127563
                     rho |  .64120306   (fraction of variance due to u_i)
            ------------------------------------------------------------------------------
            
            . reghdfe ln_wage c.age##c.age, abs(FE1=idcode FE2=year) vce(cluster idcode)
            (dropped 551 singleton observations)
            (MWFE estimator converged in 8 iterations)
            
            HDFE Linear regression                            Number of obs   =     27,959
            Absorbing 2 HDFE groups                           F(   2,   4158) =      44.91
            Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                              R-squared       =     0.6593
                                                              Adj R-squared   =     0.5995
                                                              Within R-sq.    =     0.0115
            Number of clusters (idcode)  =      4,159         Root MSE        =     0.3013
            
                                         (Std. err. adjusted for 4,159 clusters in idcode)
            ------------------------------------------------------------------------------
                         |               Robust
                 ln_wage | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                     age |   .0728746   .0136873     5.32   0.000     .0460402    .0997089
                         |
             c.age#c.age |  -.0010113   .0001076    -9.39   0.000    -.0012224   -.0008003
                         |
                   _cons |   .4586164   .3651743     1.26   0.209    -.2573205    1.174553
            ------------------------------------------------------------------------------
            
            Absorbed degrees of freedom:
            -----------------------------------------------------+
             Absorbed FE | Categories  - Redundant  = Num. Coefs |
            -------------+---------------------------------------|
                  idcode |      4159        4159           0    *|
                    year |        15           0          15     |
            -----------------------------------------------------+
            * = FE nested within cluster; treated as redundant for DoF computation
            
            . list idcode year FE1 FE2 if year==70 & idcode<=5
            
                   +-----------------------------------------+
                   | idcode   year          FE1          FE2 |
                   |-----------------------------------------|
                1. |      1     70    .39961182   -.03454909 |
               27. |      3     70   -.11767402   -.03454909 |
               40. |      4     70    .27191881   -.03454909 |
               53. |      5     70    .18536291   -.03454909 |
                   +-----------------------------------------+
            
            .
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #36
              Carlo,

              Thank you for sharing this example. This is quite helpful. I have a couple of more questions:
              1. Can I use the absorb option with xtreg?
              2. I need to have a state year fixed effect, in my model. In order to do that, can my state variable be a string variable? I guess I do it like i.state##c.year, right?

              Comment


              • #37
                Anupam:
                1) no, as the -absorb- option is not available from -xtreg-;
                2) no, your state variable should be numerical.
                Kind regards,
                Carlo
                (Stata 19.0)

                Comment

                Working...
                X