Announcement

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

  • Individual fixed effects in panel data

    Hello Xperts,

    I have the following panel data set (this is just a sample since I cannot use the real dataset for copyright reasons):
    Id year age treatment prepost salary CapInc OccId
    1 1990 23 0 0 100 234 33
    1 1991 24 0 0 212 23 33
    1 1992 25 0 0 122 23 33
    1 1993 26 0 1 345 23 33
    1 1994 27 0 1 234 2 33
    1 1995 28 0 1 11 45 33
    2 1990 33 0 0 223 23 33
    2 1991 34 0 0 678 9 22
    2 1992 35 0 0 121 9 22
    2 1993 36 0 1 33 9 22
    2 1994 36 0 1 45 12 22
    2 1995 38 0 1 67 0 22
    2 1995 39 0 1 78 5 22
    3 1990 56 1 0 23 3 11
    3 1991 57 1 0 88 5 11
    3 1992 58 1 0 99 7 11
    3 1993 59 1 1 44 21 11
    3 1994 60 1 1 11 23 11
    3 1995 61 1 1 33 3453 11
    4 1990 45 1 0 44 3 77
    4 1991 46 1 0 12 454 77
    4 1992 47 1 0 12 5 77
    4 1993 48 1 1 34 45 77
    4 1994 49 1 1 66 454 77
    4 1995 50 1 1 777 56 77

    I need to implement the following FE model (diff-in-diff) :

    Wit = Ai+ Xit*Beta + Dit*Sigma + Ci*Xit*Beta + Ci*Dit*Sigma + Errorit

    Ai = Individual fixed effects
    Wit = Salary
    Xit = contains observed time-varying characteristics of individuals
    Ci = treatment variable
    Dit = Dummy variable indicating the pre and post period

    I have the following code implemented in stata:
    Code:
     xtset id year
    Code:
     xtreg salary i.treatment##i.prepost i.treatment##c.age i.treatment##c.CapInc, fe robust
    Is my code correct?
    I am wondering the Ai component of the model that needs to capture the individual fixed effects. Does my code capture the individual fixed effects?


    Thanks a lot as usual for all your inputs.

    Regards,

    Jason

  • #2
    Jason:
    the fixed effect is actually captured by -panelid- included in -xtset-.
    That said, so many interactions look problematic to understand and disseminate.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thanks Calro!
      The first interaction
      Code:
      xtreg salary i.treatment##i.prepost, fe
      is the diff-in-diff estimator.

      The rest of the interactions are the interaction of the treatment variable with each of the time variant control.
      Hope that makes sense.

      Just to continue, what if I also need to include the occupation id (OccId) fixed effect into my model?

      Will the stata code by something like this (without controls)?
      Code:
      xtset OccId year
      xtreg salary i.treatment##i.prepost, fe robust
      Thanks as usual,

      Jason

      Comment


      • #4
        Jason:
        interactions make sense as long as they contribute to give a fair and true data generating process.
        As far as your second question is concerned, your new code change the -paneid-.My guess is that this is not what you want. If you want to control for employment just add -i.Occid- (which probably is a categorical variable) in the right-hand side of -xtreg- keeping -id- as -panelid-.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Thanks Carlo.
          This is what i understand from your comment.
          Code:
          xtset id year
          xtreg salary i.treatment##i.prepost i.OccId, fe robust
          This is the problem I have, and I would like to include it in the model. My theory suggests that an individual's salary is likely to be biased due to an occupation before the treatment year (i.e. 1992). Hence I would like to "take away" the 1992 occupation effects on the salary from 1993-1995. Hence the occupation is time invariant (thats why you see that the occupation id does not change).

          Any suggestions how can I do this? Basically I would like to include occupation and individual FE in the same model. Something like:

          Wit = Ai+ Bo + Xit*Beta + Dit*Sigma + Ci*Xit*Beta + Ci*Dit*Sigma + Errorit
          Bo = occupation fixed effects.


          Possible?
          (Apologies if my question sound very basic, I am still getting my head around FE in a panel data)

          Thanks again.

          J

          Comment


          • #6
            Jason:
            if you want to estimate more than one fixed effect, you may want to consider the community-contributed programme -reghdfe- (just type -search reghdfe- and follow the instructions to install it).
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Ah ok! This is new to me. I will take a look.
              Thanks a lot!

              J

              Comment


              • #8
                This is what I did:
                Code:
                reghdfe salary i.treatment##i.prepost, vce(robust) absorb(Id OccId)
                This is to model my individual and occupation fixed effects in one model.

                J

                Comment


                • #9
                  Jason:
                  it looks reasonable.
                  Kind regards,
                  Carlo
                  (Stata 19.0)

                  Comment


                  • #10
                    Thanks a lot Carlo!

                    Comment


                    • #11
                      Jason, if occupation does not change over time, then it is already absorbed by the individual fixed effects in your first regression (the one that uses xtreg). So you may not need to correct for it separately, unless it changes over the years, others it is captured by Ai

                      Comment


                      • #12
                        Thanks Kelvin for that point! I also realised that. When adding the additional occupation fixed effects, there is hardly any difference from my prior results when I use only individual FE!

                        Comment

                        Working...
                        X