Announcement

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

  • Recent Event study coding issue

    I'm working with repeated cross-section data and have been trying to work with all the recent DID literature. After collapsing I successfully executed Stackdev, CS , did_2s and DiD_Multiplegt. However, with my collapsed dataset for some reason, I wasn't able to run the did_computation. It returns me the error : ( I attached my collapsed data which I made a panel from repeated CS).

    Code:
     
     There are no untreated observations, i.e. those with year<treat or mi(treat). Please double-check the period & event time variables.  something that should be true of your data is not r(459);
    DID Imputation Code

    Code:
    ssc install did_imputation, replace
    
    ** did_imputation 
    
    did_imputation ln_incwage statefip year treat, horizons(0/10) pretrend(10)
    
    did_imputation ln_incwage statefip year treat, allhorizons pretrends(5)
    EVENT STUDY INTERACT Sun and Abraham Code

    Code:
    ssc install eventstudyinteract, replace
    
    ********Preparation
        sum treat
        gen lastcohort = treat==r(max) // dummy for the latest- or never-treated cohort
        forvalues l = 0/5 {
            gen L`l'event = time_to_treat==`l'
        }
        forvalues l = 1/14 {
            gen F`l'event = time_to_treat==-`l'
        }
        drop F1event // normalize K=-1 (and also K=-15) to zero
    
    eventstudyinteract ln_incwage L*event F*event, vce(statefip) absorb(statefip year) cohort(treat) control_cohort(lastcohort)


    This returns me the error that :


    Code:
     
     (obs=3,678) vcetype 'statefip' not allowed r(9);
    I usued statefip as my id for the previous recent DiD like CS, Stackdev, DiD_Mupltiplegt and did_2s. So, there shouldnt be any problem with statefip as being id of my panel data.

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float ln_incwage int year byte statefip float(treat time_to_treat)
     10.20175 1 2012 0  -4
    10.118625 1 2013 0  -3
    10.121947 1 2014 0  -2
    10.162588 1 2015 0  -1
    10.164964 1 2016 0   0
    10.240293 1 2017 0   1
    10.226054 1 2018 0   2
     10.18818 1 2019 0   3
     10.28508 1 2020 0   4
    10.265915 2 2012 0   0
    10.276074 2 2013 0   0
    10.251534 2 2014 0   0
    10.223777 2 2015 0   0
     10.36559 2 2016 0   0
    10.327884 2 2017 0   0
    10.340085 2 2018 0   0
    10.288028 2 2019 0   0
    10.350742 2 2020 0   0
    10.349242 8 2012 0 1
    10.370746 8 2013 0 2
     10.39272 8 2014 0 3
    10.357117 8 2015 0 4
     10.36257 8 2016 0 5
    10.390102 8 2017 0 6
    10.448965 8 2018 0 7
    10.453508 8 2019 0 8
    10.482086 8 2020 0 9
    10.196277 32 2012 0 -4
    10.197188 32 2013 0 -3
    10.215773 32 2014 0 -2
     10.18137 32 2015 0 -1
    10.180758 32 2016 0  0
    10.227181 32 2017 0  1
     10.18598 32 2018 0  2
     10.25193 32 2019 0  3
     10.35258 32 2020 0  4
     10.29493 6 2012 0 0
     10.31255 6 2013 0 0
    10.324828 6 2014 0 0
    10.297793 6 2015 0 0
     10.35929 6 2016 0 0
     10.38448 6 2017 0 0
    10.395014 6 2018 0 0
     10.40755 6 2019 0 0
    10.431263 6 2020 0 0
    end
    label values statefip statefip_lbl
    label def statefip_lbl 6 "California", modify

  • #2
    Mistakenly all the selected data were untreated. here all the data are from treated state if that helps

    Code:
    10.161886  5 2016 1   0
    10.205595  5 2017 1   1
      10.1783  5 2018 1   2
     10.20149  5 2019 1   3
    10.268033  5 2020 1   4
     10.49788  9 2017 1   1
    10.488782  9 2018 1   2
     10.49362  9 2019 1   3
    10.539173  9 2020 1   4
     10.22255 12 2012 1  16
    10.197344 12 2013 1  17
    10.200547 12 2014 1  18
    10.218767 12 2015 1  19
    10.210785 12 2016 1  20
    10.236649 12 2017 1  21
    10.240928 12 2018 1  22
    10.245994 12 2019 1  23
    10.264595 12 2020 1  24
    10.223028 13 2012 1   2
    10.222223 13 2013 1   3
     10.22702 13 2014 1   4
    10.250689 13 2015 1   5
    10.285876 13 2016 1   6
     10.31274 13 2017 1   7
     10.28801 13 2018 1   8
    10.259768 13 2019 1   9
    10.255515 13 2020 1  10

    Comment


    • #3
      I don't work anywhere near this territory but the immediate problem seems clear-cut You have specified a variable name to vce() but that is not what the option expects or allows. Here is an extract from the help.

      vce(vcetype [,opt]) vcetype may be unadjusted (default), robust or cluster fvvarlist (allowing two-
      and multi-way clustering)
      suboptions bw(#), kernel(str), dkraay(#) and kiefer allow for AC/HAC estimates;
      see the avar package

      Disclaimer: While I hope this detail helps, please don't expect that I can provide any further advice about these commands or your project.

      Comment


      • #4
        Mr Cox,

        As always you are very kind to put your valuable thought into helping me. I really appreciate this so much, and hopefully, after following your instruction will be able to tackle this issue I've been having a for a while. Much obliged !

        Comment


        • #5
          The issue appears to be the other DD commands understand that your panel variable means that you will cluster on that same variable.

          Regarding the first issue, I suspect that you've mistakenly coded some units as treated (in this case all of them).

          Comment


          • #6
            Thanks so much for your valuable take. After, taking Mr. Cox's and your suggestion in mind, I kept working on the issue. Then, I figured out how to do it correctly for Sun and Abraham.

            "vce(cluster statefip)" instead of "vce(statefip)". The first argument in "vce()" specifies the type of standard error estimator, which in my case is clustered.

            This is all I needed to do. Thanks again for valuable feedback !

            For, DiD_imputation I did create the treat variable wrong and then I figure out how to get around the issue by creating the gvar variable after following the helpfile. Then the following command did the trick in case anyone wants to use it for future reference:

            did_imputation ln_incwage statefip year gvar, autosample horizons(0/10) pretrend(10)
            Last edited by Tariq Abdullah; 28 Feb 2022, 14:06.

            Comment

            Working...
            X