Announcement

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

  • Interacting Variables with Time Fixed Effects - Panel Data

    Hello all!

    I'm working with a balanced panel data set where I examine 50 participants over 15 time periods. The participants are split up into a treatment group, and a control group, with treatment being administered at t=7. I'm running a simple diff-in-diff.

    t is my variable indicating time period, hence is my timevar. ID indicates which participants are which, hence ID is my panelvar. Y is my dependent variable. TreatxPost is my variable of interest, demonstrating the effect of being in the treatment group, in the post period (post period being t>6).

    Everything else are confounders that I control for. Finally, I control for 'time fixed effects', as certain years will feature shocks common to every participant.

    My code is written beneath;



    xtset t
    tabulate t, gen(AnnualFE)
    reghdfe Y TreatxPost confounder1 confounder2 confounder3 confounder4, absorb(ID t)



    I would love to ask two questions (I am a complete rookie with Stata so please bear with me!).

    1) I believe my second line of code controls for 'time fixed effects', but does my 3rd line (my regression), account for 'fixed effects'? Reading the Stata manual implies that reghdfe controls for fixed effects, but I just wanted to make sure!

    2) This is the trickier question! I have a 5th confounder that I would like to include, but don't know how! For confounder5, I have a value for every participant at t=1. However, I have no values for t>1. To be clear - each participant has a different value of confounder5 at t=1.

    I would like to control for confounder5. I've been given the following explanation but I don't really know what it means, nor how to write the code for it!

    "For each participant, you could interact the t=1 value of confounder5 with 'time fixed effects'. This would reproduce variation in confounder5 over the 15 time periods, allowing you to control for confounder5".

    Thank you for any help you can provide, and please forgive me if I'm not being clear! Furthermore, this is my first post, so I welcome any constructive criticism on how to pose questions in the future!

    Best wishes,

    Lewis






  • #2
    Welcome to Stata list. You will increase your chances of useful answer by following the FAQ on asking questions-provide Stata code in code delimiters, readable Stata output, and sample data using dataex. You also find that shorter questions have a higher probability of getting answered.

    If you don't really need the multi dimensional fixed effects, it is often best to stay with a Stata provided procedure. It is quite common to see xtreg y x1 x2 i.year, fe where the panel is your ID. In this case, you could use factor variable notation to do your interactions which would make your post estimation analysis with margins and Marginsplot much much easier.

    reghdfe is not documented in the Stata manual. It is user written and comes with its own documentation. And yes, this should work to control for time and ID.

    2) if you only have one value for each panel, you cannot include that variable if you want to run fixed effects. You can included if you're willing to move to random effects. Fixed effects will only estimate parameters on variables that vary within panels. Naturally, one could easily write the time one value forward across the panel using bysort id: egen conf=mean(confounder5).

    If you want to allow the parameter on this confounder to vary across the years of the panel, you could easily do it in xtreg with i.year##confounder. Alternatively you could assume the change in the parameters linear in year and go with c.year##confounder.

    Comment


    • #3
      Hello everyone,

      I am writing to you because I need your help. I am asked nowadays to prepare a Master Thesis that I need to present next year.

      I want to study the impact of a decrease in Public Transportation Fares on Road Congestion, and see if a substitution effect operates between cars and PT in a European country.

      For that, I have a Panel of 20 roads during 25 years (1995-2019). My question is:

      I want to compute a "beta" for each year and each road axis separately, to first look at a sort of event analysis. Does anyone know how can I proceed?

      Thank you in advance for your very appreciated help!

      Best,

      Michael Duarte


      Comment

      Working...
      X