Announcement

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

  • Treatment assignment times changes when adding covariates to xtdidregress

    Hello everyone,

    I am trying to run a double-difference model with the xtdidregress command, but I don't understand why adding covariates to my model modifies the timing on which my treatment is assigned.

    My dataset is a panel data with yearly observations of firms, with a treatment beginning in year 19. It has quite some missing values.

    Here is the output I obtain running xtdidregress on a simple model without covariates:

    Code:
    . xtdidregress (leverage3) (treatment19_balanced), group(firm) time(year)
    
    Treatment and time information
    
    Time variable: year
    Control:       treatment19_balanced = 0
    Treatment:     treatment19_balanced = 1
    -----------------------------------
                 |   Control  Treatment
    -------------+---------------------
    Group        |
            firm |       206        114
    -------------+---------------------
    Time         |
         Minimum |        16         19
         Maximum |        23         19
    -----------------------------------
    
    Difference-in-differences regression                     Number of obs = 2,260
    Data type: Longitudinal
    
                                             (Std. err. adjusted for 320 clusters in firm)
    --------------------------------------------------------------------------------------
                         |               Robust
               leverage3 | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    ---------------------+----------------------------------------------------------------
    ATET                 |
    treatment19_balanced |
               (1 vs 0)  |   .9547445   .8713181     1.10   0.274    -.7595115       2.669
    --------------------------------------------------------------------------------------
    Note: ATET estimate adjusted for panel effects and time effects.
    Note: Treatment occurs at different times and estimation sample contains units that switch in and out of
          treatment.
    However, when I try to add covariates to my model, the treatment assignment time changes, as you can see below:
    Code:
    . xtdidregress (leverage3 PPENet) (treatment19_balanced), group(firm) time(year)
    
    Treatment and time information
    
    Time variable: year
    Control:       treatment19_balanced = 0
    Treatment:     treatment19_balanced = 1
    -----------------------------------
                 |   Control  Treatment
    -------------+---------------------
    Group        |
            firm |       204        113
    -------------+---------------------
    Time         |
         Minimum |        16         19
         Maximum |        23         22
    -----------------------------------
    
    Difference-in-differences regression                     Number of obs = 2,208
    Data type: Longitudinal
    
                                             (Std. err. adjusted for 317 clusters in firm)
    --------------------------------------------------------------------------------------
                         |               Robust
               leverage3 | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    ---------------------+----------------------------------------------------------------
    ATET                 |
    treatment19_balanced |
               (1 vs 0)  |   .9151748   .8938925     1.02   0.307    -.8435583    2.673908
    --------------------------------------------------------------------------------------
    Note: ATET estimate adjusted for covariates, panel effects, and time effects.
    Note: Treatment occurs at different times and estimation sample contains units that switch in and out of
          treatment.
    For diagnostic purposes, I tried to tabulate my treatment variable treatment19_balanced, but I am still unable what modifies my treatment assignment time:
    Code:
    tab firm year if treatment19_balanced & year > 17
    
    Identifier |                          year
         (RIC) |        19         20         21         22         23 |     Total
    -----------+-------------------------------------------------------+----------
      ALAGR.PA |         1          1          1          1          1 |         5 
      ALAMA.PA |         1          1          1          1          1 |         5 
      ALAMG.PA |         1          1          1          1          1 |         5 
      ALATA.PA |         1          1          1          1          1 |         5 
      ALATI.PA |         1          1          1          1          1 |         5 
      ALAUR.PA |         1          1          1          1          1 |         5 
      ALAVI.PA |         1          1          1          1          1 |         5 
       ALBI.PA |         1          1          1          1          1 |         5 
      ALBKK.PA |         1          1          1          1          1 |         5 
      ALBON.PA |         1          1          1          1          1 |         5 
      ALBOO.PA |         1          1          0          0          0 |         2 
      ALBOU.PA |         1          1          1          1          1 |         5 
      ALBPS.PA |         1          1          1          1          1 |         5 
      ALCAP.PA |         1          1          1          1          1 |         5 
      ALCBI.PA |         1          1          1          1          1 |         5 
      ALCHI.PA |         1          1          1          1          1 |         5 
      ALCIS.PA |         1          1          1          1          1 |         5 
      ALCLS.PA |         1          1          1          1          1 |         5 
      ALCOI.PA |         1          1          1          1          1 |         5 
      ALCOX.PA |         1          1          1          0          0 |         3 
      ALCYB.PA |         1          1          0          1          1 |         4 
      ALDAR.PA |         1          1          1          1          1 |         5 
      ALDBL.PA |         1          1          1          1          1 |         5 
      ALDEL.PA |         1          1          1          1          1 |         5 
      ALDEV.PA |         1          1          1          1          1 |         5 
      ALDLT.PA |         1          1          1          1          1 |         5 
      ALDMS.PA |         1          1          1          1          1 |         5 
      ALDNX.PA |         1          1          1          1          1 |         5 
      ALDRV.PA |         1          1          1          1          1 |         5 
      ALDSL.PA |         1          1          1          1          1 |         5 
      ALDUB.PA |         1          1          1          1          1 |         5 
      ALDUX.PA |         1          1          1          1          1 |         5 
      ALDVI.PA |         1          1          1          1          1 |         5 
      ALECP.PA |         1          1          1          1          1 |         5 
      ALEMS.BR |         1          1          1          1          1 |         5 
      ALEMV.PA |         1          1          1          1          1 |         5 
      ALEUA.PA |         1          1          1          1          1 |         5 
      ALEUP.PA |         1          1          1          1          1 |         5 
      ALEXA.PA |         1          1          1          1          1 |         5 
      ALFLE.PA |         1          1          1          1          1 |         5 
      ALGAE.PA |         1          1          1          1          1 |         5 
      ALGEC.PA |         1          1          1          1          1 |         5 
      ALGEV.PA |         1          1          1          1          1 |         5 
      ALGID.PA |         1          1          1          1          1 |         5 
      ALGIL.PA |         1          1          1          1          1 |         5 
      ALGIR.PA |         1          1          1          1          1 |         5 
      ALHEX.PA |         1          1          1          1          1 |         5 
       ALHF.PA |         1          1          1          1          1 |         5 
      ALHGR.PA |         1          1          1          1          1 |         5 
      ALHOP.PA |         1          1          1          1          1 |         5 
      ALHRS.PA |         1          1          1          1          1 |         5 
      ALHYP.PA |         1          1          1          1          1 |         5 
      ALICA.PA |         1          1          1          1          1 |         5 
      ALIMP.PA |         1          1          1          1          1 |         5 
      ALINN.PA |         1          1          1          1          1 |         5 
      ALINS.PA |         1          1          1          1          1 |         5 
      ALINV.PA |         1          1          1          1          1 |         5 
      ALISP.PA |         1          1          1          1          1 |         5 
      ALITL.PA |         1          1          1          1          1 |         5 
      ALJXR.PA |         1          0          0          0          0 |         1 
      ALKEY.PA |         1          1          1          1          1 |         5 
      ALKKO.PA |         1          1          1          1          1 |         5 
      ALKLK.PA |         1          1          1          1          1 |         5 
      ALLAM.PA |         1          1          1          1          1 |         5 
      ALLAN.PA |         1          1          1          1          1 |         5 
      ALLDL.PA |         1          1          1          1          1 |         5 
      ALLEC.PA |         1          1          1          1          1 |         5 
      ALLEX.PA |         1          1          1          1          1 |         5 
      ALLUX.PA |         1          1          1          1          1 |         5 
      ALMCP.PA |         1          1          1          1          1 |         5 
      ALMDT.PA |         1          1          1          1          1 |         5 
      ALMER.PA |         1          1          1          1          1 |         5 
      ALMIB.PA |         1          1          1          1          1 |         5 
      ALMII.PA |         1          1          0          0          0 |         2 
      ALMKT.PA |         1          1          1          1          1 |         5 
      ALMRB.PA |         1          1          1          1          1 |         5 
      ALNMG.PA |         1          1          1          0          0 |         3 
      ALNN6.PA |         1          1          1          1          1 |         5 
      ALNOV.PA |         1          1          1          1          1 |         5 
      ALNSE.PA |         1          1          1          1          1 |         5 
      ALNTG.PA |         1          1          1          1          1 |         5 
      ALORA.PA |         1          1          1          1          1 |         5 
      ALPDX.PA |         1          1          1          1          1 |         5 
      ALPJT.PA |         1          1          1          1          1 |         5 
       ALPM.PA |         1          1          1          1          1 |         5 
      ALPRG.PA |         1          1          0          0          0 |         2 
      ALPRI.PA |         1          1          1          1          1 |         5 
      ALPRO.PA |         1          1          1          1          1 |         5 
      ALREA.PA |         1          1          1          1          1 |         5 
      ALRGR.PA |         1          1          1          1          1 |         5 
      ALRIB.PA |         1          1          1          1          1 |         5 
      ALRPD.PA |         1          1          0          1          1 |         4 
      ALSAF.PA |         1          1          1          1          1 |         5 
      ALSEN.PA |         1          1          1          1          1 |         5 
      ALSGD.PA |         1          1          1          1          1 |         5 
      ALSOG.PA |         1          1          1          1          1 |         5 
      ALSTW.PA |         1          1          1          1          1 |         5 
      ALTME.PA |         1          1          1          1          1 |         5 
      ALTRO.PA |         1          1          1          1          1 |         5 
      ALU10.PA |         1          1          1          1          1 |         5 
      ALVAL.PA |         1          1          1          1          1 |         5 
      ALVIO.PA |         1          1          1          1          1 |         5 
       ALVU.PA |         1          1          1          1          1 |         5 
      CHMS.EUA |         1          1          1          1          1 |         5 
     MLFMV.EUL |         1          1          1          1          1 |         5 
      MLHK.EUA |         1          1          1          1          1 |         5 
     MLNEU.EUB |         1          1          0          0          0 |         2 
     MLRZE.EUL |         1          1          1          1          1 |         5 
     MLSEQ.EUA |         1          1          1          1          1 |         5 
     MLSUM.EUA |         1          1          1          1          1 |         5 
       SNG.EUL |         1          1          1          1          1 |         5 
       SYMA.BR |         1          1          1          1          1 |         5 
      TRDL.EUA |         1          1          1          1          1 |         5 
      ZCCM.EUA |         1          0          1          1          1 |         4 
    -----------+-------------------------------------------------------+----------
         Total |       114        112        107        107        107 |       547
    Any help on this would be greatly appreciated!

  • #2
    missing data?

    Comment


    • #3
      Re #2: that's what I thought, too, at first. But it's very odd: when the covariate is added, the maximum time in the treatment group increases from 19 to 22. But if we are losing observations due to missing data, the maximum value of any variable should either decrease or stay the same.

      Comment


      • #4
        Hi all,

        I would need to look at the data to ascertain exactly what is happening. The tabulation is based on the estimation sample. Therefore, a group for which we observed treatment for the first time in period 19, in the first sample, now might not have treated observations until period 22.

        Emile, I would suggest you tabulate your data after estimation of each case based on e(sample). Also, feel free to send your data to [email protected] and we can take a closer look.

        Comment


        • #5
          Therefore, a group for which we observed treatment for the first time in period 19, in the first sample, now might not have treated observations until period 22.
          Yes, but we are not talking about the first time treatment is observed; it is the last time that is changing. And if you remove observations from a sample where the maximum value of the time variable is 19, the resulting maximum must be 19 or less, no? How can it go up to 22 when you remove observations?

          Comment


          • #6
            Hi Clyde,

            It actually is the first time treatment is observed within each group that is being presented. Here is a toy example that illustrates what is happening.

            Code:
            . clear 
            
            . // Generate balanced data
            . set obs 100 
            Number of observations (_N) was 0, now 100.
            
            . generate id = _n 
            
            . expand 7 
            (600 observations created)
            
            . bysort id: generate t = _n 
            
            . generate treat = 0 
            
            . replace treat  = 1 if id>30 & t>3
            (280 real changes made)
            
            . generate y = 3 + 3*treat + rnormal()
            
            . // Estimate balanced data 
            . xtset id t 
            
            Panel variable: id (strongly balanced)
             Time variable: t, 1 to 7
                     Delta: 1 unit
            
            . xtdidregress (y) (treat), group(id) time(t)
            
            Treatment and time information
            
            Time variable: t
            Control:       treat = 0
            Treatment:     treat = 1
            -----------------------------------
                         |   Control  Treatment
            -------------+---------------------
            Group        |
                      id |        30         70
            -------------+---------------------
            Time         |
                 Minimum |         1          4
                 Maximum |         1          4
            -----------------------------------
            
            Difference-in-differences regression                       Number of obs = 700
            Data type: Longitudinal
            
                                               (Std. err. adjusted for 100 clusters in id)
            ------------------------------------------------------------------------------
                         |               Robust
                       y | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
            -------------+----------------------------------------------------------------
            ATET         |
                   treat |
               (1 vs 0)  |   2.996809   .1472834    20.35   0.000     2.704567    3.289051
            ------------------------------------------------------------------------------
            Note: ATET estimate adjusted for panel effects and time effects.
            
            . // Introduce a gap 
            . generate x = runiform()
            
            . replace  x = . if id==40 & t==4
            (1 real change made, 1 to missing)
            
            . xtdidregress (y x) (treat), group(id) time(t)
            
            Treatment and time information
            
            Time variable: t
            Control:       treat = 0
            Treatment:     treat = 1
            -----------------------------------
                         |   Control  Treatment
            -------------+---------------------
            Group        |
                      id |        30         70
            -------------+---------------------
            Time         |
                 Minimum |         1          4
                 Maximum |         1          5
            -----------------------------------
            
            Difference-in-differences regression                       Number of obs = 699
            Data type: Longitudinal
            
                                               (Std. err. adjusted for 100 clusters in id)
            ------------------------------------------------------------------------------
                         |               Robust
                       y | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
            -------------+----------------------------------------------------------------
            ATET         |
                   treat |
               (1 vs 0)  |   3.000653   .1466857    20.46   0.000     2.709596    3.291709
            ------------------------------------------------------------------------------
            Note: ATET estimate adjusted for covariates, panel effects, and time effects.
            Note: Treatment occurs at different times.
            In the example the first time we observe treatment has a minimum and a maximum of 4 without missing observations. With a gap introduced by missing values in a covariate this changes.

            Comment


            • #7
              Thank you, I see it now.

              Comment


              • #8
                Thank you Clyde and George for your suggestion, you're right, I think missing data is the responsible here. Also thank you Enrique for your answer and your example, that makes things more clear. I use proprietary data so I'm not sure whether I have the right to share it here.

                I think I found a way to address the problem; I'm a beginner with Stata, but still here is my code, in case it is helpful to anyone.

                Code:
                *Generate a year dummy
                gen POST19 = 0
                replace POST19 = 1 if year>=19
                
                *Generate the treatment*year dummy (my treatment is the adoption of IFRS accounting norms)
                gen treatment19=POST19*IFRS
                
                *As individuals can be treated at various times, I then create a dummy that takes value 1 only if an individual is treated for the first time in 2019
                egen first = min(year) if treatment19, by(firm)
                gen treatment19_balanced = 0
                replace treatment19_balanced = 1 if (treatment19 == 1 & first == 19)
                
                *Lastly, I sum the values of the dummy, and exclude those that are different from 0 (i.e. control group) or 5 (i.e. remain treated from 2019 until 2023 included)
                egen sum_treated = total(treatment19_balanced), by(firm)
                drop if (sum_treated>0 & sum_treated <5)
                With this, I don't have the problem anymore, and lose only very few observations (74) . Thank you all!

                Comment

                Working...
                X