Announcement

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

  • How to fix treatment assignment times vary problem in postestimation codes

    Hello, after running 2x2 DiD model using xtdidregress command, attempted postestimation encounters the following problem.
    Code:
    estat trendplots
    treatment assignment times vary; not allowed with estat trendplots
    r(459);
    I intended to generate the variables based on the fact that treatment occurred only to chaebol30 group in 1998.
    However, it turns out that treatment assignment times vary, thus not allowing estat trendplots to run.
    I guess that I coded key variables incorrectly but fail to identify the source of problem and how to fix it. Any insight or tip, please?
    Code:
    *Creating treatment group
    gen treated = (chaebol30 == 1) if !missing(chaebol30)
    
    *Creating post treatment period
    gen postreform = (year>=1998) if !missing(year)
    gen did = postreform*treated
    
    xtset uniqueid year
    
    Panel variable: uniqueid (unbalanced)
     Time variable: year, 1991 to 2011, but with gaps
             Delta: 1 unit
    
    . 
    . xtdidregress (lshare2  assets ebit lnl lnk) (did), group(uniqueid) time(year)
    
    Treatment and time information
    
    Time variable: year
    Control:       did = 0
    Treatment:     did = 1
    -----------------------------------
                 |   Control  Treatment
    -------------+---------------------
    Group        |
        uniqueid |       318         72
    -------------+---------------------
    Time         |
         Minimum |      1991       1998
         Maximum |      1996       2008
    -----------------------------------

    The simplified dataset is the following:
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(uniqueid year postreform chaebol30 lshare2 assets ebit lnl lnk)
    1 1991 0 0  .3332821   12150840320  1.9535e+10  6.861712 23.431915
    1 1992 0 0  .3065908   15652244480  1.9583e+10  6.887553  23.73835
    1 1993 0 0  .2921529   16448676864  2.1049e+10  6.884487  23.83263
    1 1994 0 0  .3681257   19630718976  2.1987e+10  6.925595  24.02132
    1 1995 0 0  .3496965   29004148736  2.5398e+10  6.891626  24.12565
    1 1996 0 0  .3526861   28329910272  2.3048e+10  6.877296 24.197716
    1 1997 0 0  .3633547   27457734656  2.1745e+10  6.877296 23.570583
    1 1998 1 0  .3303979   62851514368  2.6131e+10  6.811244   24.2849
    1 1999 1 0  .2031249   59374006272  2.3642e+10  6.684612 24.308714
    1 2000 1 0  .6594473   50737635328   1.458e+09   6.60665  24.40697
    1 2001 1 0  .4051696   48560914432   1.297e+10  6.638568  24.43152
    1 2002 1 0  .4049267   47311761408  1.4847e+10  6.719013 24.464577
    1 2003 1 0  .4589242   47004819456  1.7434e+10  6.736967    24.479
    1 2004 1 0  .5271757   49855225856  1.0951e+10  6.694562  24.51651
    1 2005 1 0   .745551   52740091904  1.4652e+10  6.687109  24.55461
    1 2006 1 0  .7291619   55601311744  1.5643e+10  6.708084  24.61615
    1 2007 1 0   .722166   54124978176  1.4171e+10  6.719013  24.66132
    1 2008 1 0  .6468757   86702661632  3.3545e+10  6.747587 24.682966
    1 2009 1 0 .55281746  282336067584  3.9964e+10  6.791222 24.699453
    1 2010 1 0  .6360234  157558128640  1.0317e+10  6.700731 25.856627
    1 2011 1 0  .5350225  188283830272  2.5622e+10  6.697034  25.90188
    2 1991 0 1  .3661191   10936289280   5.767e+09  6.692084 23.618286
    2 1992 0 1  .4229154   12898647040   4.538e+09  6.704414  23.73416
    2 1993 0 1  .3244569   11287138304  -4.747e+09  6.098074  23.72624
    2 1994 0 1   .409352    9529315328   -2.20e+08  5.666427  23.50243
    2 1995 0 1 .57483864   37506891776  -6.382e+09  5.236442    23.499
    2 1996 0 1  .4623841  121718743040  1.4423e+10  6.755769  24.96295
    2 1998 1 1  .4816791  108296421376  -7.817e+09  6.309918  25.00756
    2 2001 1 1  .7003492   42262237184   5.231e+09  6.161207  24.43679
    2 2002 1 1 .10596538   40720175104   1.616e+09  6.033086 24.481195
    2 2003 1 1  .3328503   3.72611e+10  -5.042e+09  5.993961  24.53496
    2 2005 1 1 1.2392806   35817164800    8.72e+08  6.228511  24.59965
    2 2006 1 1 1.8664225   35961765888  -7.542e+09  6.204558  24.68687
    2 2007 1 1  .5690384   25966047232  -3.297e+09  5.955837  24.60003
    2 2008 1 1  3.235922   5.57511e+10    8.09e+08  5.894403 24.623646
    2 2010 1 1  .6779019   54416277504   6.851e+09  5.616771  24.68772
    2 2011 1 1  .9749503   57632022528   2.082e+09  5.575949 24.591793
    3 1991 0 0  .3394834   5.95884e+10    4.31e+09  7.665753  25.25339
    3 1992 0 0  .3588687   7.25643e+10   1.446e+09  7.597898 25.277357
    3 1993 0 0  .4686894  117664964608   1.894e+09  7.561642 25.326374
    3 1994 0 0  .4117235  122744766464   9.909e+09  7.580189   25.8834
    3 1995 0 0 .36455715  1.204281e+11   7.595e+09  7.523481  25.90187
    3 1996 0 0  .3895906  1.228812e+11   5.207e+09  7.441907  25.96245
    3 1997 0 0  .4240108  114541060096  1.6769e+10  7.403061  25.91032
    3 1998 1 0   .326054  106027761664   2.409e+10  7.428333  25.91152
    3 1999 1 0  .3632548    9.9029e+10  1.8606e+10  7.428333   25.9185
    3 2000 1 0   .350228  4.453853e+11   4.132e+09  7.342779  25.73189
    3 2001 1 0   .413291  4.359018e+11   2.674e+09  7.265429    25.729
    3 2002 1 0  .3254811  4.269574e+11   6.795e+09  7.290293 25.741364
    3 2003 1 0  .3959368  4.161738e+11  -1.304e+09  7.034388  25.74615
    3 2004 1 0 1.5411386  4.065097e+11  -6.935e+09  7.013016 25.738005
    3 2005 1 0  .6214045  3.984453e+11   3.432e+09   6.96319  25.74296
    3 2007 1 0 .21773556  5.123636e+11 -1.3155e+10  6.790097  25.69178
    3 2009 1 0  .3935431 1.3172757e+12  -9.594e+09   6.36647 27.203924
    3 2010 1 0 .19970874 1.3018633e+12  4.1705e+10  6.284134  27.21099
    3 2011 1 0  .3828388  3.086942e+11  2.2577e+10  6.385194 25.662464
    4 1991 0 0 .29655632  1.973641e+11  5.0114e+10  8.295548 26.762653
    4 1992 0 0  .3310919  268046647296  6.3193e+10  8.250359 26.871416
    4 1993 0 0  .3567093  322450161664  4.6005e+10  8.230044 27.022476
    4 1994 0 0   .397345   4.14316e+11  2.9957e+10  8.209309  27.25725
    4 1995 0 0 .29255465   4.18093e+11  4.9073e+10  8.167352  27.39054
    4 1996 0 0  .4127857  4.970855e+11   1.659e+10 8.1847925  27.40442
    4 1997 0 0  .3296258  4.690049e+11  4.1049e+10  7.988882  27.45299
    4 1998 1 0 .29136083  6.877812e+11 1.66954e+11  7.935945 27.372503
    4 1999 1 0 .25516528  635290058752  5.8183e+10  7.806289  27.38952
    4 2000 1 0  .2799891  6.216094e+11  6.9867e+10  7.767264 27.410067
    4 2001 1 0 .17636837  3.934757e+11  5.2907e+10  7.082549  26.23344
    4 2002 1 0   .234349   3.70657e+11  5.4334e+10  7.102499  26.29709
    4 2003 1 0 .30857405  3.786105e+11  4.0414e+10  7.082549 26.386675
    4 2004 1 0   .356524  3.774268e+11  5.0614e+10  7.118826  26.43069
    4 2005 1 0  .3849443  3.827659e+11  4.2939e+10  7.154615  26.47537
    4 2006 1 0  .5057777  3.884834e+11  4.5386e+10  7.132498  26.55257
    4 2007 1 0  .6345179  3.803304e+11  5.4165e+10  7.081708  26.59785
    4 2008 1 0  3.235922  3.784612e+11  2.5946e+10  7.096721     26.64
    4 2009 1 0 .29052773  3.655785e+11    5.30e+10  7.074963 26.667366
    4 2010 1 0  .2595637  3.619287e+11  3.1476e+10   7.06732 26.703707
    4 2011 1 0  .1621215   4.27543e+10  6.8076e+10  5.135798 22.850906
    5 1991 0 1 .24546757   64434081792   4.279e+09  7.467942 24.887163
    5 1992 0 1   .359291  126992334848  1.2601e+10  7.511525 25.157526
    5 1993 0 1  .2714617  2.466127e+11  2.9302e+10  7.501082 25.329826
    5 1994 0 1 .25080284  2.913828e+11  4.4333e+10  7.627544 25.788897
    5 1995 0 1 .25646988  229389156352   4.174e+10   7.64874  25.86832
    5 1996 0 1  .2703185  3.405388e+11  3.7966e+10  7.699389 25.928566
    5 1997 0 1 .25005215  3.834322e+11  6.0865e+10  7.596894 25.899134
    5 1998 1 1 .19216697  3.893109e+11  7.9211e+10  7.504392  25.92809
    5 1999 1 1 .17665446  3.575237e+11 1.07148e+11  7.418781 25.915674
    5 2000 1 1 .11374114  3.821297e+11 1.36248e+11  7.567863 26.037374
    5 2001 1 1  .3156508  3.854991e+11 1.12281e+11  7.648263  26.04502
    5 2002 1 1  .4514445  4.697997e+11  9.5959e+10   7.60589 26.165104
    5 2009 1 1  .3449082  6.244763e+11 1.14167e+11  7.373374  26.52544
    5 2010 1 1  .3611461   6.25502e+11  8.6934e+10  7.366445  26.55831
    5 2011 1 1   .736477 2.1038635e+12  9.0966e+10  8.131236  28.21211
    6 1991 0 0  .4849912   16305367040   8.804e+09  7.337588 23.935875
    6 1992 0 0 .51733065   17650604032   8.212e+09  7.338888  24.07287
    6 1993 0 0 .54159594   26197358592   8.908e+09  7.312553 24.136194
    6 1994 0 0 .52930063   36605095936   7.741e+09  7.273093  24.19478
    6 1995 0 0 .50165474  1.421752e+11  1.0398e+10  7.257003 24.280895
    6 1996 0 0  .5191442  173824655360  1.2785e+10   7.26333 24.355743
    6 1997 0 0  .4456724  154611580928  1.6069e+10  7.161622  25.07311
    6 1998 1 0   .334461  1.548169e+11  2.1326e+10  7.028202 25.081173
    end

  • #2
    I don't see anything wrong with your code. The problem is almost surely with the data. Unfortunately, the data example you posted does not exhibit the problems you are encountering: the -estat trendplots- command runs just fine with this example.

    My best guess about the problem is this: your -xtset- output indicates that there are gaps in the panels. Probably there are some uniqueid's for which there is no observation with year == 1998. For such uniqueid's, -xtdidregress- will identify the start date of treatment as 1999 (or whatever the next non-missing year after 1998 is), and that leads to your problem. The best solution is to fill in the gaps in the data, if feasible. If that's not feasible, then you will have to generate the trend plots using basic Stata commands instead of the convenience command -estat trendplots-.

    Comment


    • #3
      Clyde Schechter Thanks Clyde, do you mean I need to fill in the gaps for control variables used in the code above or for other variables as well? The following is my missing observation status and it seems that at least I have no missing observation issue for those key covariates used in the regression.
      Code:
      misstable sum
                                                                     Obs<.
                                                      +------------------------------
                     |                                | Unique
            Variable |     Obs=.     Obs>.     Obs<.  | values        Min         Max
        -------------+--------------------------------+------------------------------
                 roi |       460               6,850  |   >500     -.7304       .7684
        first_year~t |     5,976               1,334  |      6       1991        1996
        chaebol30_~2 |     5,976               1,334  |   >500          0    169.4545
        obs_pre_co~t |     5,696               1,614  |      2          5           6
              pscore |     5,696               1,614  |     84   .0119934    .6994085
             _pscore |     5,696               1,614  |     84   .0119934    .6994085
            _treated |     5,696               1,614  |      2          0           1
            _support |     5,696               1,614  |      1          1           1
             _weight |     5,696               1,614  |      1          1           1
            _lshare2 |     6,514                 796  |     37   .1730005      .60457
               _pdif |     6,514                 796  |     42   .0000554    .0468627
                pair |     5,696               1,614  |     42          9         262
        -----------------------------------------------------------------------------

      Comment


      • #4
        There are two different problems in the data that can lead to gaps.

        The first is if a particular uniqueid simply has no observation in year 1998. Any such uniqueid is a problem here and a 1998 observation should be found if possible.
        That won't show up in your -misstable summarize- results.

        To appear in the -misstable summarize- results there has to be an observation but the value of a variable mentioned in the -xtdidregress- command is missing. Any such observation is automatically excluded from the estimation sample for -xtdidregress-. And if such observation has year == 1998, this creates a problematic gap as well. For these observations the key is to fill in the missing values in the observation(s).

        Looking at it affirmatively, in order to use -estat ptrends- every uniqueid in your dataset must have an observation with year == 1998, and that observation must have non-missing values for all of the variables mentioned in the -xtdidregress- command. Any uniqueid whose observations don't meet this requirement needs fixing.

        Comment


        • #5
          Clyde Schechter Thank you, it makes sense. Just one more quick question: if some of 1998 observation were gone due to propensity score matching, which I did before running xtdidregress, should I give up using -estat trendplots- ?
          Last edited by Chul-Kyoo Jung; 02 Apr 2024, 21:28.

          Comment


          • #6
            It makes no difference why the 1998 observation is missing: if it's missing it will block you from using -estat trendplots-.

            Comment

            Working...
            X