Hello all,
Please note that I have seen the thread on subject 'csdid gvar error' however, the solutions did not address my error the same way. I continue to run into the issue.
An extract of data is pasted below and also attached a snapshot.
Receive the following error Gvar max value is 18628 and there are no periods available before that treatment
Verify that Gvar is correctly defined
request may not be combined with by
r(190);
I get the error no matter the sample i try. Please advise how to solve the problem.
My sample is made of 7 units. 6 of them receive treatment at different dates and one is a never-treated unit.
We have data on all units until December 2023. However, the starting date of data for each unit differs due to availability.
The treatment dates are:
Hope I have laid out the problem well. Thanks in advance!
Please note that I have seen the thread on subject 'csdid gvar error' however, the solutions did not address my error the same way. I continue to run into the issue.
An extract of data is pasted below and also attached a snapshot.
Code:
import excel "$path\Data Structure.xlsx", sheet("EG Model Data") firstrow clear rename *, lower *Setting up event dates bysort i: gen datenum=_n bysort i: gen target=datenum if month==eventdate //date of joining programme egen td = min(target), by(i) gen dif = datenum-td // difference between any date and joining date gen TE = td if dif>=0 replace TE = 0 if dif<0 replace TE=0 if dif==. sort td TE dif xtset i datenum csdid yoy, ivar(i) time(month) gvar(TE)
Receive the following error Gvar max value is 18628 and there are no periods available before that treatment
Verify that Gvar is correctly defined
request may not be combined with by
r(190);
I get the error no matter the sample i try. Please advise how to solve the problem.
My sample is made of 7 units. 6 of them receive treatment at different dates and one is a never-treated unit.
We have data on all units until December 2023. However, the starting date of data for each unit differs due to availability.
The treatment dates are:
Oct-17 |
Mar-18 |
Aug-18 |
Dec-22 |
Jan-23 |
Oct-23 |
Hope I have laid out the problem well. Thanks in advance!
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(i treated) int month double(grosslending yoy) int eventdate float(datenum target td dif TE) 3 1 19510 5972000 1.1783695057450303 21093 30 . 82 -52 0 3 1 19936 9865000 4.575021192427239 21093 44 . 82 -38 0 3 1 20940 24195000 -.4591724970382457 21093 77 . 82 -5 0 3 1 19540 30772500 2.638271458973753 21093 31 . 82 -51 0 3 1 18779 5717000 4.378174976481656 21093 6 . 82 -76 0 3 1 19206 1843000 -.5677767354596623 21093 20 . 82 -62 0 3 1 18628 4953500 .3763545429285913 21093 1 . 82 -81 0 3 1 18659 4305000 -.3468365953573054 21093 2 . 82 -80 0 3 1 18687 1360000 -.6747967479674797 21093 3 . 82 -79 0 3 1 19237 765000 -.8238950276243093 21093 21 . 82 -61 0 3 1 19084 12128198 3.7363747485989887 21093 16 . 82 -66 0 3 1 19390 4446000 .3976736875196478 21093 26 . 82 -56 0 3 1 20789 45398000 .5539277768269724 21093 72 . 82 -10 0 3 1 19632 11869500 .14173720661792988 21093 34 . 82 -48 0 3 1 19449 20366000 .6792272025901951 21093 28 . 82 -54 0 3 1 19053 4290000 2.1544117647058822 21093 15 . 82 -67 0 3 1 21001 33286615 .22399018084871303 21093 79 . 82 -3 0 3 1 19783 7276000 -.6623274161735699 21093 39 . 82 -43 0 3 1 20910 27728689 2.038760438356164 21093 76 . 82 -6 0 3 1 21063 4293000 -.5722399362295736 21093 81 . 82 -1 0 3 1 19844 10077000 1.5530782873068154 21093 41 . 82 -41 0 3 1 18840 4264000 . 21093 8 . 82 -74 0 3 1 19967 19809000 .6072210953346855 21093 45 . 82 -37 0 3 1 20089 7738500 -.3990448085734255 21093 49 . 82 -33 0 3 1 20240 17797500 3.935524126455907 21093 54 . 82 -28 0 3 1 20301 14451000 .4648758236188546 21093 56 . 82 -26 0 3 1 20393 24755000 .28344048112816256 21093 59 . 82 -23 0 3 1 20454 11491000 .48491309685339545 21093 61 . 82 -21 0 3 1 18901 3087000 1.3528963414634148 21093 10 . 82 -72 0 3 1 20636 27195165.06 -.2224087580346319 21093 67 . 82 -15 0 3 1 20698 10036000 -.5894461142911492 21093 69 . 82 -13 0 3 1 20423 29215000 1.4893490115882755 21093 60 . 82 -22 0 3 1 20362 25114000 .8777524393435268 21093 58 . 82 -24 0 3 1 20759 44450500 .7956170470611998 21093 71 . 82 -11 0 3 1 20820 12256800 .06664346009920807 21093 73 . 82 -9 0 3 1 20606 47726000 1.6816125860373647 21093 66 . 82 -16 0 3 1 18748 5865650 .9917317487266553 21093 5 . 82 -77 0 3 1 19114 7425000 .2658443650746294 21093 17 . 82 -65 0 3 1 19267 10396000 2.3676708778749593 21093 22 . 82 -60 0 3 1 18932 5395500 .4330677290836653 21093 11 . 82 -71 0 3 1 20485 18503000 2.74782256431031 21093 62 . 82 -20 0 3 1 20270 34973600 .40659588159588167 21093 55 . 82 -27 0 3 1 20332 24445025 .23403629663284375 21093 57 . 82 -25 0 3 1 20148 13796000 .8960967564595932 21093 51 . 82 -31 0 3 1 18718 2560650 .9431986340352874 21093 4 . 82 -78 0 3 1 19997 13374500 .12679556847381934 21093 46 . 82 -36 0 3 1 20575 44737000 1.4537531942341162 21093 65 . 82 -17 0 3 1 19693 15348180.76 .6081497024308467 21093 36 . 82 -46 0 3 1 19905 24864000 -.1920058493785035 21093 43 . 82 -39 0 3 1 19755 10735000 1.4145299145299144 21093 38 . 82 -44 0 3 1 20728 25495000 .015170821055984662 21093 70 . 82 -12 0 3 1 20879 11534500 .15634085213032578 21093 75 . 82 -7 0 3 1 19875 3606000 -.39618218352310786 21093 42 . 82 -40 0 3 1 20851 25311138 .3679477922499055 21093 74 . 82 -8 0 3 1 19602 12325000 15.11111111111111 21093 33 . 82 -49 0 3 1 20514 9975000 -.2769643374891273 21093 63 . 82 -19 0 3 1 18993 480000 -.9030988190168567 21093 13 . 82 -69 0 3 1 19175 8458000 .11124249471181002 21093 19 . 82 -63 0 3 1 20545 9125000 -.547072225227953 21093 64 . 82 -18 0 3 1 18962 6601490 .3371460401053272 21093 12 . 82 -70 0 3 1 20058 11736000 -.23534911508300482 21093 48 . 82 -34 0 3 1 19328 9544000 .4457342206077719 21093 24 . 82 -58 0 3 1 19145 2741500 -.5204652789924786 21093 18 . 82 -64 0 3 1 19359 7798000 15.245833333333334 21093 25 . 82 -57 0 3 1 19418 21547500 4.0227272727272725 21093 27 . 82 -55 0 3 1 19663 10180000 .7348329925017041 21093 35 . 82 -47 0 3 1 20971 36199000 -.24152453589238565 21093 78 . 82 -4 0 3 1 21032 31851500 1.4030327854322517 21093 80 . 82 -2 0 3 1 19814 14946000 -.26612982421683196 21093 40 . 82 -42 0 3 1 20179 20146700 .3479660109728355 21093 52 . 82 -30 0 3 1 19724 12877000 .6513208515003848 21093 37 . 82 -45 0 3 1 19024 3181000 -.26109175377468063 21093 14 . 82 -68 0 3 1 20209 18232070 .8092755780490226 21093 53 . 82 -29 0 3 1 18871 4344000 1.0423131170662905 21093 9 . 82 -73 0 3 1 18809 7611300 3.614307365868445 21093 7 . 82 -75 0 3 1 19571 1769500 -.039880629408572954 21093 32 . 82 -50 0 3 1 20120 4937000 -.5401024685607825 21093 50 . 82 -32 0 3 1 20667 13254708.879999999 -.0827825839042281 21093 68 . 82 -14 0 3 1 19479 3947000 -.4684175084175084 21093 29 . 82 -53 0 3 1 19298 5868000 .08757297748123438 21093 23 . 82 -59 0 3 1 20028 19288000 .8946954813359529 21093 47 . 82 -35 0 3 1 21275 20589000 -.25748382839159834 21093 88 . 82 6 82 3 1 22980 36827870 -.500089589995458 21093 144 . 82 62 82 3 1 23315 15772260 -.574800640538311 21093 155 . 82 73 82 3 1 23011 19585700 -.4595070593554563 21093 145 . 82 63 82 3 1 22493 89526600 1.2005358371841508 21093 128 . 82 46 82 3 1 21458 32871403 -.1553795555075922 21093 94 . 82 12 82 3 1 22615 73668940 .368085241238014 21093 132 . 82 50 82 3 1 22677 38791100 -.4781442685291468 21093 134 . 82 52 82 3 1 21366 19577280 -.41185728858281323 21093 91 . 82 9 82 3 1 21216 17755000 -.29853015696093954 21093 86 . 82 4 82 3 1 21244 23964630 1.0776479257878537 21093 87 . 82 5 82 3 1 21428 15776920 2.675033775914279 21093 93 . 82 11 82 3 1 22646 36236736 1.9189453313007352 21093 133 . 82 51 82 3 1 21305 44198145.38 .8267470708824138 21093 89 . 82 7 82 3 1 22462 73408000 1.2587666287415744 21093 127 . 82 45 82 3 1 21731 29469100 .5052703950702038 21093 103 . 82 21 82 3 1 21609 35232560 .47019002588397996 21093 99 . 82 17 82 3 1 23042 33634510 -.13293229632570358 21093 146 . 82 64 82 3 1 22889 92772985 .4175297360345689 21093 141 . 82 59 82 end format %td month format %tdMon-YY eventdate
Comment