Announcement

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

  • Difference-in-difference with three time periods

    Hi statalist,

    I’m running a difference in difference model with time fixed effects. My sample includes women who were observed two or three times out of the three waves of my data. I have three survey waves (2006, 2012, 2018) and a treatment that occurs at different times (either 2006 or 2012). The treatment is whether or not a specific woman has given birth to a male child.

    I created a dummy variable for when the treatment started – so that the year 2006 takes a value of 0 and 2012/2018 take value of 1. I created a second dummy variable for my treatment. Any women who has given birth between 2006-2012 or 2012-2018 is coded as 1, all other women who have not given birth to a son are coded 0. I then generated my difference-in-difference estimator and ran my regression

    Code:
    gen year=round
    recode year 6=0 12=1 18=1
    gen did = year*sonbirth
     
    xtreg C1 i.year i.sonbirth i.did  [pweight= panel_wt_06_12_18] , fe
    The treatment variable is omitted due collinearity- which I don’t think should happen.

    Because I have more than one-time period, do I just add year dummies and interact that with my treatment variable without indicating whether the different years belong to the pre/post period?
    Different women might have experienced the treatment at different times. I realise this question has been asked a few times, but I haven’t been able apply them to my specific dataset.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double Findid byte round float year str3 sonCH float(sonbirth did)
    601004603  6 0 ".10" 0 0
    601004603 12 1 ".10" 0 0
    601004603 18 1 ".10" 0 0
    601005902  6 0 "000" 0 0
    601005902 12 1 "000" 0 0
    601005902 18 1 "000" 0 0
    601019206  6 0 ".10" 0 0
    601019206 12 1 ".10" 0 0
    601019206 18 1 ".10" 0 0
    601025702  6 0 "00." 0 0
    601025702 12 1 "00." 0 0
    601025702 18 1 "00." 0 0
    601032309  6 0 ".10" 0 0
    601032309 12 1 ".10" 0 0
    601032309 18 1 ".10" 0 0
    601033103  6 0 ".00" 0 0
    601033103 12 1 ".00" 0 0
    601033103 18 1 ".00" 0 0
    601036602  6 0 "00." 0 0
    601036602 12 1 "00." 0 0
    601036602 18 1 "00." 0 0
    601037505  6 0 ".10" 0 0
    601037505 12 1 ".10" 0 0
    601037505 18 1 ".10" 0 0
    601051404  6 0 ".10" 0 0
    601051404 12 1 ".10" 0 0
    601051404 18 1 ".10" 0 0
    601054402  6 0 "010" 1 0
    601054402 12 1 "010" 1 1
    601054402 18 1 "010" 1 1
    601056302  6 0 "110" 1 0
    601056302 12 1 "110" 1 1
    601056302 18 1 "110" 1 1
    601058302  6 0 "010" 1 0
    601058302 12 1 "010" 1 1
    601058302 18 1 "010" 1 1
    601058602  6 0 "000" 0 0
    601058602 12 1 "000" 0 0
    601058602 18 1 "000" 0 0
    601059402  6 0 "11." 1 0
    601059402 12 1 "11." 1 1
    601059402 18 1 "11." 1 1
    601060002  6 0 "111" 1 0
    601060002 12 1 "111" 1 1
    601060002 18 1 "111" 1 1
    601060202  6 0 "010" 1 0
    601060202 12 1 "010" 1 1
    601060202 18 1 "010" 1 1
    601060302  6 0 "000" 0 0
    601060302 12 1 "000" 0 0
    601060302 18 1 "000" 0 0
    601061802  6 0 "010" 1 0
    601061802 12 1 "010" 1 1
    601061802 18 1 "010" 1 1
    601062002  6 0 "000" 0 0
    601062002 12 1 "000" 0 0
    601062002 18 1 "000" 0 0
    601062602  6 0 "010" 1 0
    601062602 12 1 "010" 1 1
    601062602 18 1 "010" 1 1
    601063102  6 0 "110" 1 0
    601063102 12 1 "110" 1 1
    601063102 18 1 "110" 1 1
    601067002  6 0 "11." 1 0
    601067002 12 1 "11." 1 1
    601067002 18 1 "11." 1 1
    601070802  6 0 "110" 1 0
    601070802 12 1 "110" 1 1
    601070802 18 1 "110" 1 1
    601071602  6 0 "110" 1 0
    601071602 12 1 "110" 1 1
    601071602 18 1 "110" 1 1
    601071702  6 0 "110" 1 0
    601071702 12 1 "110" 1 1
    601071702 18 1 "110" 1 1
    601071902  6 0 "11." 1 0
    601071902 12 1 "11." 1 1
    601071902 18 1 "11." 1 1
    601072002  6 0 "010" 1 0
    601072002 12 1 "010" 1 1
    601072002 18 1 "010" 1 1
    601072702  6 0 "000" 0 0
    601072702 12 1 "000" 0 0
    601072702 18 1 "000" 0 0
    601072902  6 0 "010" 1 0
    601072902 12 1 "010" 1 1
    601072902 18 1 "010" 1 1
    601073102  6 0 "11." 1 0
    601073102 12 1 "11." 1 1
    601073102 18 1 "11." 1 1
    601073402  6 0 "110" 1 0
    601073402 12 1 "110" 1 1
    601073402 18 1 "110" 1 1
    601074502  6 0 "000" 0 0
    601074502 12 1 "000" 0 0
    601074502 18 1 "000" 0 0
    601075502  6 0 "110" 1 0
    601075502 12 1 "110" 1 1
    601075502 18 1 "110" 1 1
    601075902  6 0 "110" 1 0
    end
    label values round yr
    label def yr 6 "2006", modify
    label def yr 12 "2012", modify
    label def yr 18 "2018", modify

  • #2
    Following the advice on here (https://www.statalist.org/forums/for...e-time-periods), I have managed to figure out my DID regression. I run it and get the following output:

    Code:
    xtreg C1 i.sonbirth##i.year [pweight= panel_wt_06_12_18] , fe
    note: 1.sonbirth omitted because of collinearity
    
    Fixed-effects (within) regression               Number of obs     =      8,535
    Group variable: Findid                          Number of groups  =      3,540
    
    R-sq:                                           Obs per group:
         within  = 0.0617                                         min =          2
         between = 0.0068                                         avg =        2.4
         overall = 0.0387                                         max =          3
    
                                                    F(4,3539)         =      50.49
    corr(u_i, Xb)  = -0.0034                        Prob > F          =     0.0000
    
                                  (Std. Err. adjusted for 3,540 clusters in Findid)
    -------------------------------------------------------------------------------
                  |               Robust
               C1 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    --------------+----------------------------------------------------------------
       1.sonbirth |          0  (omitted)
                  |
             year |
               1  |  -.2650297   .1011778    -2.62   0.009    -.4634024    -.066657
               2  |   .4925483    .110355     4.46   0.000     .2761825    .7089141
                  |
    sonbirth#year |
             1 1  |   .2409295   .1094579     2.20   0.028     .0263226    .4555365
             1 2  |   .0648046     .12598     0.51   0.607     -.182196    .3118053
                  |
            _cons |  -.0330636   .0306437    -1.08   0.281    -.0931447    .0270174
    --------------+----------------------------------------------------------------
          sigma_u |  .97452112
          sigma_e |  1.3278496
              rho |  .35006812   (fraction of variance due to u_i)
    ----------
    My treatment is omitted (given fe specification) and I have my DID estimator results. When I come to graph them using margins i.sonbirth##i.year - It is not estimable. I am not sure why that might be the case? If I cannot graph, how can I interpret the results of the DID estimates?

    Also, I have seen a few papers where an F test is used to test the null hypothesis that there is no difference before or after treatment. Using the stata test command, I tested the equivalency of 1 1 = 1 2, which was statically insignificant. Does that then mean that the treatment has no effect on my outcome variable (continuous measure of participation in household decisions)?
    Last edited by Sherine Maui; 13 Apr 2021, 09:16.

    Comment


    • #3
      Sherine: This all looks too hard to me. I think it's trying to force it into the basic DID framework that's causing the problem. It looks to me like you have three time periods (records) for each mother -- which makes things easier.

      Here is what I suggest. Define a treatment indicator for each woman in each of the three time periods. Set it to zero in the first time period and then turn it on when appropriate for each mother. I think this shouldn't be difficult. Given this variable -- call call it "treat" -- there is no need for the interactions as you've tried to include them. I just find that way of doing it confusing.

      Once you have the "treat" variable, just use

      Code:
      xtreg C1 treat i.year, fe cluster(id)

      Comment


      • #4
        Thank you, Jeff - your way seems much less complicated and results are making good sense.

        Comment

        Working...
        X