Announcement

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

  • xtdidregress using continous treatment variable - ERROR insufficient observations

    Hi,

    I have survey data on individual firms from 2008-2017. I want to test how a reform that happened in 2013 that affected all individuals influenced their earnings. My testing hypothesis is that the effect is going to be dependent on the level of pre-reform competition (measured by number of rival firms in 10km radius). So my treatment variable is "dd3 = reform=(years>=2014) * prereform_comp".

    I am trying to run xtdidregress command with continuous treatment variable but I am getting error as "insufficient observations".

    My objective is to run this DiD regression and then be able to do postestimation for graphical diagnostics of parallel trends. But this can only happen if I am able to run the main model specification first.

    The code I am running is as:

    Code:
    xtdidregress (lannualY hrs) (dd3, continuous), group(xwaveid) time(years)
    insufficient observations


    I am attaching a sample of observations that I have. Any help to get this running would be most appreciated.

    Thanks.


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long xwaveid float(years lannualY dd3 hrs)
    1100002 2008 11.686398     0   32
    1100002 2009 11.997396     0   36
    1100002 2010  11.85281     0   34
    1100002 2011 12.017887     0   36
    1100002 2012 11.614816     0   34
    1100002 2013 11.682918     0   30
    1100005 2008  12.74331     0   36
    1100005 2010 12.758693     0   32
    1100005 2011 12.752957     0   41
    1100008 2008  12.59228     0   55
    1100008 2009 12.577435     0   50
    1100008 2010 12.639094     0   50
    1100008 2011  12.41624     0   48
    1100008 2012 12.679445     0   47
    1100008 2013  12.38578     0   48
    1100008 2014 12.518613    39   40
    1100008 2015  12.47567    39   31
    1100010 2011  12.26209     0   35
    1100010 2014 12.788903    41   35
    1100010 2016 11.567077    41   30
    1100011 2008 12.194057     0   38
    1100011 2009 12.345364     0   32
    1100011 2010 12.163589     0   35
    1100011 2011 11.619886     0   25
    1100012 2008  11.00119     0   12
    1100012 2009 11.150636     0   18
    1100012 2011 11.163477     0   20
    1100012 2012 11.502678     0   32
    1100012 2013 12.120378     0   30
    1100012 2014 11.673064 124.4   35
    1100012 2015  11.87079 124.4   35
    1100012 2016 12.270066 124.4   30
    1100012 2017  11.98143 124.4   33
    1100013 2008  12.57995     0   33
    1100013 2009  13.01717     0   41
    1100013 2010 12.785512     0   46
    1100013 2013  13.03439     0   50
    1100014 2008 10.430075     0   21
    1100014 2009 10.281137     0   11
    1100014 2010   9.88554     0   20
    1100021 2008   11.9355     0   30
    1100021 2009 11.795596     0   36
    1100021 2010 11.405168     0   25
    1100021 2011 11.704503     0   29
    1100021 2012  11.44317     0   30
    1100021 2013  11.83622     0   32
    1100028 2008 11.156384     0   16
    1100028 2009 11.494257     0   15
    1100028 2010 11.583652     0   18
    1100028 2011 11.855001     0   18
    1100028 2012  11.44317     0   18
    1100028 2013 11.478524     0   18
    1100028 2014 12.241905 137.2   19
    1100028 2015 12.293347 137.2   19
    1100028 2016 11.781213 137.2   21
    1100028 2017 12.045792 137.2   23
    1100030 2009  11.52969     0   17
    1100030 2010  11.65244     0   26
    1100030 2011 11.677086     0   29
    1100030 2012  11.73967     0   28
    1100030 2013  11.83622     0   32
    1100030 2015 11.804792  27.2   31
    1100030 2016  11.81769  27.2   27
    1100030 2017 11.259967  27.2   33
    1100031 2009 10.720964     0   18
    1100031 2011 10.086025     0   14
    1100031 2012 10.327307     0   17
    1100032 2009 13.217962     0   54
    1100032 2010  12.98266     0   60
    1100032 2011 12.950105     0   50
    1100032 2012 13.058546     0   50
    1100032 2013 12.908464     0   50
    1100032 2014  12.89323  42.2   38
    1100032 2015  12.62509  42.2   48
    1100032 2016 12.770346  42.2   50
    1100032 2017 12.844865  42.2   45
    1100035 2008 12.320346     0   42
    1100035 2012 11.860375     0   46
    1100036 2008  12.09435     0 40.5
    1100036 2009  11.76374     0   30
    1100036 2010 11.421727     0   30
    1100036 2011  11.47933     0   30
    1100036 2013 11.419016     0   26
    1100036 2014  11.97863  29.8   24
    1100036 2016  11.76276  29.8   24
    1100036 2017 10.661768  29.8   27
    1100037 2012  12.41897     0   43
    1100037 2015 12.825226  55.2   40
    1100037 2016 13.234243  55.2   40
    1100037 2017 12.799034  55.2   42
    1100040 2008 11.200836     0   17
    1100040 2009  11.35276     0   17
    1100040 2010 11.768997     0   21
    1100040 2012 12.163022     0   25
    1100040 2013  11.92321     0   28
    1100040 2014 12.321003 226.8   30
    1100040 2015  12.18087 226.8   30
    1100040 2016  12.34998 226.8   27
    1100040 2017  12.23112 226.8 26.5
    1100043 2008 11.088202     0   36
    end

  • #2
    Dear Kushneel,

    Below is what I am getting with the data you provided. I made an assumption about your panel and your time variables. Please let me know if the assumption I made was incorrect. Also, feel free to send your data and code to technical support, [email protected], and we will look at your issue. Also, note that currently the graphical diagnostics are only available for a binary treatment.

    Code:
    . xtset xwaveid  years
    
    Panel variable: xwaveid (unbalanced)
     Time variable: years, 2008 to 2017, but with gaps
             Delta: 1 unit
    
    . xtdidregress (lannualY hrs) (dd3, continuous), group(xwaveid) time(years)
    
    
    Difference-in-differences regression                       Number of obs = 100
    Data type: Longitudinal
    
                                   (Std. err. adjusted for 18 clusters in xwaveid)
    ------------------------------------------------------------------------------
                 |               Robust
        lannualY | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    ATET         |
             dd3 |   .0025543   .0009081     2.81   0.012     .0006385    .0044701
    ------------------------------------------------------------------------------
    Note: ATET estimate adjusted for covariates, panel effects, and time effects.

    Comment


    • #3
      Thank you Enrique for your reply.

      Yes, your assumptions are correct and that is exactly how I had xtset my data. I will try again on my Stata17 - its weird I did not get any result with the same specifications as you typed in.

      But following your note that graphical diagnostics are not available for continuous treatment (which I am looking for ultimately), can you please suggest me a suitable specification that will allow me to graph this. Thanks.

      Comment


      • #4
        Hi,

        I am using my university licensed Stata/MP17.0. Any insights on what is going on.


        xtset xwaveid years

        Panel variable: xwaveid (unbalanced)
        Time variable: years, 2008 to 2017, but with gaps
        Delta: 1 unit

        xtdidregress (lannualY hrs) (dd3, continuous), group(xwaveid) time(years)
        insufficient observations
        r(2001);

        Comment


        • #5
          Dear Kushneel,

          With regard to the error message, please send your data and do-file to technical support and we will look into it. With regard to your issue, another alternative is to try to do the estimation with -xtreg, fe-. Here is what I would type:

          Code:
          xtreg lannualY hrs dd3 i.years, fe vce(robust)
          With regard to the graphing of parallel trends, usually you have a treated group and an untreated group. In the case of intensities, it is unclear what it means to be untreated. You may want to define a threshold for no treatment in your case and then proceed as as suggested here https://www.statalist.org/forums/for...nce-estimation

          Comment


          • #6
            Hi Enrique,

            The command worked now. I note that my Stata was not updated. After updating it works fine. Thanks again.

            I am now looking through the other link. Thanks for sharing.

            Comment

            Working...
            X