Announcement

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

  • Generate treatment variables for panel data analysis

    Dear community,

    I am working on a panel data analysis, where I have to generate a treatment variable. The panel data only covers two waves of household data, one from 2019 and one from 2022.
    The treatment variable should indicate that at least one household member was contracted with Covid-19. The problem is that my treatment dummy only indicates the value of one for the year 2022 but not for the same subject in 2019.

    The commands I used so far are:

    gen time = 1 if year==2022,
    replace time = 0 if year==2019,

    xtset QID time

    gen treated= 1 if cov_infected_cov!=0,
    replace treated = 0 if cov_infected_cov==0


    I would be very thankful for any advice to fix this problem.

    Best regards!


  • #2
    Felix:
    welcome to this forum.
    Some comments about your query:
    1) why creating a time variable when you seemingly have one already (year)?
    2) as per your first chunck of code I'd say you're after a difference in difference study (pre/post; treatment/control).
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hello Mr. Lazzaro,
      thank you for the response, I am a beginner in Stata.

      I generated the time variable because I was told to do so in order to have a time dummy.

      Yes, I want to apply the difference in difference and the problem is that the treatment variable is not showing the value of one for the treated subjectives for the year 2019.

      I am looking forward to your response.

      Kind regrads,
      Felix

      Comment


      • #4
        Felix:
        1) the issue seems to be that in 2019 the pandemic did not outbreak yet: hence, the value of the variable -covid_infected- should be zero regardless of the group.
        2) I'm fine with the creation of a -timevar-. However, if -year- variable is in numeric format already, you can simply code -i.year- to create a predcitor.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Dear Mr. Lazzaro,

          thank you for your help.
          I will work further with your advice.

          Kind regards,
          Felix

          Comment

          Working...
          X