Announcement

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

  • DiD estat trendplots Error

    Hi, I am writing my Master's thesis using a DiD design to establish whether extreme weather events influence party vote shares in 93 electoral districts within the state of New South Wales, Australia.

    I have a 3 waves panel data from 2011, 2015 and 2019 - where treatment occurs in 2019 - as follows:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long id int year double(GRN_vc ALP_vc CDP_vc INF_vc) byte treated
     1 2011  .08387307462036685 .20981875578294237   .03423501877755402  .07105535296358788 0
     1 2015  .13861543347094316  .6142690801312586   .06303588440774849  .14459616809569176 0
     1 2019  .10239012676606914  .2700340648908248  .027670743284748982  .09487909755961356 1
     2 2011  .08387307462036685 .41377991345717086   .03803581247459896  .10621817399411891 0
     2 2015  .13861543347094316  .6659801264679314  .061860885275519424   .1277687443541102 0
     2 2019  .10239012676606914  .4779970760233918   .02867933723196881  .11829922027290449 0
     3 2011  .13861543347094316 .16737507775243624  .027057847812564793  .04457806344598798 0
     3 2015  .13861543347094316 .41314537568210435   .03372044214355674  .07226808451098363 0
     3 2019  .13861543347094316 .27241254468932435   .02036475539666018  .04984839570982486 0
     4 2011  .08387307462036685 .23536568246689438  .010130550746338497  .04445276309016892 0
     4 2015  .08387307462036685  .4162042895616341  .013173691553911548 .052143158441221325 0
     4 2019  .08387307462036685  .3351045235265329  .007108065906919294  .03442168309678622 0
     5 2011  .05894108421239028 .39672661961498573  .045407401785940146  .12830436872328047 0
     5 2015 .059581158838485214  .6877759935768768   .05315803559480797   .1481332798073063 0
     5 2019 .057137098805864865  .5129994457600645  .028492971229908803  .14455585226986448 0
     6 2011  .03500990846465981 .18873266018684534   .02912774055550313  .05715454059324966 0
     6 2015  .11071749326414529  .6423011675481489   .05857698832451851   .1479393274124339 0
     6 2019 .044201135442011354 .36824448868244486  .025989825259898253  .10318513603185137 0
     7 2011  .08898842658519535  .2658778448074981  .026176112678973667  .05201563835020583 0
     7 2015   .1736752608116182  .6389080380532194   .04761248219127717   .1158141458706742 0
     7 2019  .08101883965483754  .3185261230265531   .02341777420160373  .09003634749313282 0
     8 2011  .09682601611089436  .1673054414430955  .047139283501250774  .04266403506758772 0
     8 2015  .19360766189654213   .546801046828888   .09298958739350743  .11531822484548138 0
     8 2019  .08442634267568687  .2428551705094574   .03849693957384141  .05370702747480326 0
     9 2011  .14880531214281825 .23237903445272956  .020600881728623524 .059190115930985686 0
     9 2015  .21801312514143473  .6152070604209097   .03113826657614845  .11016066983480426 0
     9 2019  .12410727299227518  .3391390953699655   .01464801049409707  .07909439828985085 0
    10 2011  .05935044788069859 .41029875394084975    .0607516388930591  .08104388730420858 0
    10 2015  .07631328252585738  .6800149700598802   .07709580838323353   .1220059880239521 0
    10 2019  .07118199914329629  .5051276236551012   .04986519515206491  .10348476831204173 0
    11 2011   .2629617587474677  .2322236950704049  .053147587724783035  .03796613560763325 0
    11 2015   .3105217542035015  .5490032934650719  .061813139192234356  .06534928063789218 0
    11 2019  .18258846577690707  .4272560303661075  .041973796987878044 .049810211828088646 1
    12 2011  .07858207804226004 .20387126625880417  .027376484499511595   .0493290833376176 0
    12 2015 .043911439114391146  .7273062730627307   .05178351783517835   .1173739237392374 0
    12 2019  .06820748324926598  .5502020125975557  .035283194057567316   .1375944189314663 0
    13 2011  .06882448346378958 .44171779141104295  .026302799520485157  .09573842935383024 0
    13 2015  .10150533138197784  .6165586452017562   .07113736148860547  .14744929960275976 0
    13 2019  .05520998580612841  .3342448025381982  .028867830007514403  .09100776488269183 0
    14 2011  .06074243456261555 .25114332976549575   .03303493237326068  .06076676072783886 0
    14 2015  .07852797372448027  .7093643862202814   .05326017989773448  .11984473556525958 0
    14 2019  .06619248476828495  .5088909105946572  .041656328398533345  .10738014501144101 0
    15 2011  .07432489156289353 .36177417098083114   .04371064782426193  .07992164544564152 0
    15 2015  .13329596063409013  .6108879130461864   .07315705876856957   .1355694665047183 0
    15 2019  .11730697500932488  .4498787765759045   .03639033942558747  .10886795971652369 0
    16 2011   .1584559163659913 .35826625959848274  .029951891941900267  .08347210657785178 0
    16 2015  .19521828055575147  .5068058396219761   .10177022357006842  .13393046054023555 0
    16 2019  .07080117114719191 .20235560287463403   .03105314523999645  .05243545381953686 0
    17 2011  .08153877376147203  .1511037950706925    .0393938710623041 .036191850632511784 0
    17 2015  .09349044499966237  .7516037544736309  .028901343777432642  .10037814842325613 0
    17 2019  .08358068184970457  .5435102221975644  .019362534328275404   .1010014147410469 0
    18 2011  .10423751686909581 .42496626180836705  .030742240215924428  .08950067476383265 0
    18 2015  .16809939556749495  .6649764942914708  .036937541974479515  .10782404298186703 0
    18 2019  .12682118386227026 .46065748138620227   .02288074801494051  .07329260147920943 0
    19 2011   .1259625239809729  .3084807232398623   .02509789493048803 .062468791884575964 0
    19 2015      .1984558454018  .5976974736168852  .059116451185526976  .12024304445155101 0
    19 2019  .10950379387521153   .296195207161963   .02953217970413232  .08166384627981876 0
    20 2011  .10232496346485984    .20438421681945  .032336920419821974 .056915105619768834 0
    20 2015   .2477768983658457  .5320545649238791   .07667954746496577  .11606685599888263 0
    20 2019   .1397749834546658 .28955658504301784  .032111184645929845  .08031767041694242 0
    21 2011   .1339757845317519 .18715097603162836    .0383493946132938 .054138868297504326 0
    21 2015   .3831039593478721 .49769214482320556  .017361846284141436  .07355494389159432 0
    21 2019   .1922368321429473  .3462887716730182 .0072432677990056284  .04308103879060142 0
    22 2011   .2532732717867485 .20508378090735838  .012523822488429077 .040714798406058954 0
    22 2015  .08470853615101508  .6628873323044046   .06713759943013178  .14697851121928054 0
    22 2019  .03888034086874186 .24855012427506215  .024766244525979406  .09069120605988874 1
    23 2011  .08855183580170484  .1738178008476594  .034073051097671316  .04943092528215629 0
    23 2015   .2161597156893488  .5270199644611686   .08043273753527752  .13588376711612835 0
    23 2019  .08791056497436134 .23890146440615329  .021735113410634267 .060562664572458076 0
    24 2011   .1262233016644046 .08052956163535491  .022358739909993573 .036740719575207755 0
    24 2015   .3974358974358974  .3828218413710642  .062309020858243656  .10814401487976617 0
    24 2019  .14584073311074802 .15500461746110678  .020482583883876773  .04392507873363169 0
    25 2011    .124570834839176 .22757047343693532   .02139049512106975  .05088995301770871 0
    25 2015  .25369606758523583  .5300211203862013  .039676154078246005  .12375540581313486 0
    25 2019  .11526532590259268  .2726920281075842  .016719166464744365  .06014053792100799 0
    26 2011 .049691741856957634  .1748471939248009   .04622549149313365  .06448284073770275 0
    26 2015  .10841195412688549   .625783854019547   .08282017965086719  .14564148918140218 0
    26 2019 .057748062244837584 .27811963789124905   .03591503461333649  .10463877877048695 0
    27 2011   .0649546827794562  .3519125403246454   .04862000102411798  .07616877464283886 0
    27 2015  .08240772548570556  .6682316118935837   .07588075880758807  .12950875987633115 0
    27 2019  .05802309424560395  .4143069330650184   .04285851181064635   .0985098941114465 0
    28 2011   .1495206753469738 .16979062336051892   .04757476033767349    .037201316354271 0
    28 2015   .3135040635040635 .45601020601020603   .09610659610659611  .09350784350784351 0
    28 2019  .12072966204884325 .26677694304684446   .04335240195740575  .04457003698853585 0
    29 2011  .06335347575771993  .3993909692153971   .05462244849407622  .11854689061236143 0
    29 2015   .0475268491907427  .6463772500378158   .10591438511571623  .13674179397973074 0
    29 2019 .062468050301605155  .5282690931397608   .04237807995092526   .1374603823739904 0
    30 2011   .1319585608973574 .27895471577967723   .03105483578653474  .05740736205334182 0
    30 2015  .17441100734078943  .6602098466505246   .03781851723740343  .10365502133056613 0
    30 2019  .10830588176125934  .4095606910252219  .022782709281565117  .08358689365554355 0
    31 2011  .11731334738595259 .19699690321909075   .04244411481510396  .05701720144689931 0
    31 2015  .17073170731707318  .6495218047865282   .05175490779298037  .10497414542625727 0
    31 2019  .09783289817232375  .3522976501305483  .021879895561357703  .07091383812010443 0
    32 2011 .061003109497021056    .34771772413302   .04809038904317691  .09584846542761519 0
    32 2015  .07424805185347025  .6061102614521885   .13440390357585028    .143543805986454 0
    32 2019  .05413227300181196  .4527884034628548  .036214012482383734  .11979061807932354 0
    33 2011  .07758040171833275 .10974108905143388   .03367003367003367 .039916405433646815 0
    33 2015  .19815504701082137  .5164094376441369   .07864703447460233  .16149251966175862 0
    33 2019  .08357907383136741  .2368665356050677  .030935998252512014  .08281454783748361 0
    34 2011  .17522642793571017 .23443798753991937   .04143762106695985 .048060310978482804 0
    end
    label values id id
    label def id 1 "Albury", modify
    label def id 2 "Auburn", modify
    label def id 3 "Ballina", modify
    label def id 4 "Balmain", modify
    label def id 5 "Bankstown", modify
    label def id 6 "Barwon", modify
    label def id 7 "Bathurst", modify
    label def id 8 "Baulkham Hills", modify
    label def id 9 "Bega", modify
    label def id 10 "Blacktown", modify
    label def id 11 "Blue Mountains", modify
    label def id 12 "Cabramatta", modify
    label def id 13 "Camden", modify
    label def id 14 "Campbelltown", modify
    label def id 15 "Canterbury", modify
    label def id 16 "Castle Hill", modify
    label def id 17 "Cessnock", modify
    label def id 18 "Charlestown", modify
    label def id 19 "Clarence", modify
    label def id 20 "Coffs Harbour", modify
    label def id 21 "Coogee", modify
    label def id 22 "Cootamundra", modify
    label def id 23 "Cronulla", modify
    label def id 24 "Davidson", modify
    label def id 25 "Drummoyne", modify
    label def id 26 "Dubbo", modify
    label def id 27 "East Hills", modify
    label def id 28 "Epping", modify
    label def id 29 "Fairfield", modify
    label def id 30 "Gosford", modify
    label def id 31 "Goulburn", modify
    label def id 32 "Granville", modify
    label def id 33 "Hawkesbury", modify
    label def id 34 "Heathcote", modify

    In order to get an estimate of any party voteshare, I coded in Stata 17:
    xtdidregress (GRN_vc) (treatment), group(id) time(year)
    estat trendplots, omeans

    The estat trendplots shows
    treatment assignment times vary; not allowed with estat trendplots
    r(459);

    However, my treatment assignments times do not vary : treatment happened in 2019 for all districts that were affected.

    Could you please provide me with some clarity as to what I am missing?

    Many thanks for your time and help !











  • #2
    what does Stata return if you type -display e(tmin)- after running the regression?
    Last edited by Øyvind Snilsberg; 07 Aug 2022, 07:01.

    Comment


    • #3
      Stata displays 2011 if I type -display e(tmin)- after running the regression.

      Comment


      • #4
        so at least one district is recorded as treated before 2019. to see all districts that are treated before 2019 and in which year(s) type -tab id year if treated & year < 2019-

        Comment


        • #5
          Works now !! Thank you so much

          Comment


          • #6
            Hi again, I am having the same problem with another dataset with the same structure for which I have 5 years - from 2004, 2008, 2012, 2016 and 2020. Treatment happens in 2012 for which I code a dummy in 2012 (1 in 2012, 0 other years).
            I type :
            didregress (GRN_vc) (treatment), group(id) time(year)
            estat trendplots, omeans

            for which Stata returns the same error message : "treatment assignment times vary; not allowed with estat trendplots
            r(459);".

            I checked the problem with -display e(tmin)- for which i get 2012 and the data is perfectly clean. Yet the parallel trends graph will not appear.

            Again, am I missing something? Please let me know!
            Best,

            Comment

            Working...
            X