Announcement

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

  • Interaction in manual DID

    Hello,

    Im running a DID model( over two waves of a longitudinal survey) where the code that I use is;

    Code:
    reg  `y' i.treatment##i.post  $controls i.PERSONID , cl(PSUID)
    Suppose I wanted to find the effect for various age cohort separately, which is generated using the following code,

    Code:
    recode agecohort(15/22=1) (23/29=2) (30/36=3) (37/43=4) (43/50=5) , gen(cbin)
    the data is like this,

    [CODE]----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(agecohort cbin)
    45 5
    33 3
    26 2
    19 1
    36 3
    40 4
    27 2
    40 4
    26 2
    36 3
    32 3
    28 2
    49 5
    29 2
    28 2
    34 3
    Should I run the code like this?
    Code:
    reg  `y' i.treatment##i.post  $controls i.PERSONID if cbin==1 , cl
    or this
    Code:
    reg  `y' i.treatment##i.post##i.cbin  $controls i.PERSONID , cl
    But if I do the latter, the coefficient in stata will not show for the cbin==1.

    Please clarify what the difference is between the two.

    Or third option is I define my treatment in a way that it is in cbin==1 ,2,3 respectively and do
    Code:
    reg  `y' i.treatment##i.post  $controls i.PERSONID , cl(PSUID)
    separately for the differently defined treatments.

    which one is the right way to go about it?

  • #2
    There is no need to define the two variables "treatment" and "post" separately. Just create a treated indicator (=1 if an individual in a survey wave is treated and zero otherwise). Then you can use the margins command to get all levels. In the regression, the level that is not estimated is referred to as the base or reference category and needs to be omitted as it combined with the included levels are collinear with the constant term.

    Code:
    gen treated=treatment & post
    *TREATMENT EFFECTS ACROSS COHORTS
    regress outcome i.treated##i.cbin $controls i.PERSONID i.WAVE, cluster(PERSONID)
    
    *MARGINS
     margins treated#cbin
    Please clarify what the difference is between the two.
    Clearly, in one case you are restricting the sample to one cohort and in the other, you are using the full sample and including interactions to identify the cohort effects. You would need to combine estimated results if you pursue the subsample analyses and wish to run tests of cross-model hypotheses. See, e.g., the discussion in the documentation on suest.

    Code:
    help suest
    Last edited by Andrew Musau; 13 Jan 2023, 03:02.

    Comment


    • #3
      The post variable that I use is the survey wave indicator.
      post==1 (if wave2) and post==0 (ifwave1).

      Maybe I'll try to describe my research question.
      Im trying to use the exogenous variation of a household members death across two waves as treatment.

      so treatment=death of household member

      So I did i.treatment##i.post so that my treatment variable would mean death in wave two.
      Since i.treatment##i.post already regresses i.post , that's why I didn't add i.wave separately.

      Is this method right?

      Comment


      • #4
        Originally posted by Eve Alexander View Post
        So I did i.treatment##i.post so that my treatment variable would mean death in wave two.
        So the suggestion in #2 is to create a treated indicator instead of specifying it as an interaction between 2 variables. In this way, you avoid triple interactions once you further interact the treated variable with the cohort indicators.

        Code:
        gen treated= 1.treatment#1.post

        Since i.treatment##i.post already regresses i.post , that's why I didn't add i.wave separately.
        Now, no need to cause confusion by calling the wave indicator something else. I suggest

        Code:
        gen wave2=1.post
        regress outcome i.treated##i.cbin $controls i.PERSONID i.wave2, cluster(PERSONID)
        margins treated#cbin

        Comment


        • #5
          Thank you for your time and help.

          Comment

          Working...
          X