I am trying to find the correct way to perform a staggered DiD regression where the outcome variable Y is the value of transactions over fortnightly time intervals in different countries before and after a treatment event. With basic panel data I know to xtset in stata by providing the panel id and time variable. However, in my data I am looking at two different types of transactions before and after the event (a control group and treatment group in the form of a dummy variable). This complicates the panel id.
"bifirst_case" represents the number of periods before the treatment takes effect in that country
"countryid" is the country in which the deal is taking place, and "pandemic2" is the dummy measuring whether a deal belongs to the control group or treatment group. "bimonth" is the time variable representing a fortnightly period. "logval" is log of "value" of transaction.
Code:
* Example generated by -dataex-. For more info, type help dataex clear bifirst_case bimonth countryid logval pandemic2 panelid value 54 1 22 1.81827 0 32 6.1611904 55 1 48 2.7242925 0 75 15.245625 54 1 45 -.41551545 0 70 .66 54 1 112 2.442263 0 183 11.499035 57 1 104 3.5263605 0 168 34 56 1 52 1.252763 0 82 3.5 57 1 75 -.8556661 0 117 .425 55 1 38 3.98549 0 60 53.8116 55 1 100 1.2919532 0 161 3.63988 55 1 12 2.2940488 0 16 9.915 55 1 111 .8916701 0 181 2.4392000 54 1 36 1.109034 0 57 3.0314 54 1 5 .59332687 0 5 1.81 53 1 25 3.2770064 0 38 26.49633 54 1 106 -2.4769385 0 172 .084 54 1 99 1.7084503 0 159 5.5203 55 1 35 -.47965 0 55 .619 57 1 79 2.2016592 0 125 9.04 54 1 56 1.926436 0 88 6.865 57 1 50 1.460087 0 79 4.30633 57 1 11 -3.218876 0 14 .04 54 1 114 -.8209805 0 186 .44 57 1 47 3.582963 0 74 35.98 54 1 95 1.7340715 0 151 5.663 57 1 78 -.25489226 0 123 .775 58 1 23 1.0030187 0 34 2.72649 57 1 31 2.3066518 0 48 10.04075 55 1 87 -3.218876 0 140 .04 55 1 103 1.9268 0 166 6.8675 55 1 100 2.484907 1 162 12 54 1 114 1.0986123 1 187 3 53 1 25 3.822098 1 39 45.7 57 1 11 -3.218876 1 15 .04 57 1 98 .8837675 1 158 2.42 55 1 111 2.944439 1 182 19 54 1 22 1.9603295 1 33 7.10166 57 1 50 -.10314076 1 80 .902 55 1 12 1.2837077 1 17 3.61 55 1 87 -3.218876 1 141 .04 54 1 56 2.926382 1 89 18.66 54 1 36 1.1118575 1 58 3.04 55 1 53 1.9789304 1 85 7.235 57 1 17 1.9600948 1 24 7.1 54 1 112 2.0537095 1 184 7.796769 54 1 68 .9555115 1 107 2.6 54 1 5 1.974081 1 6 7.2 55 2 103 1.5534317 0 166 4.727666 57 2 84 -1.258781 0 134 .284 57 2 31 -.8891621 0 48 .411 58 2 55 .6523252 0 87 1.92 54 2 68 1.2933564 0 106 3.645 54 2 99 3.391551 0 159 29.7119 57 2 78 2.589642 0 123 13.325 54 2 56 1.8112516 0 88 6.1181 54 2 5 .11800523 0 5 1.12524999 55 2 100 .22314355 0 161 1.25 57 2 15 3.753027 0 21 42.65 57 2 93 -3.296837 0 148 .037 54 2 112 1.8774613 0 183 6.536888 57 2 49 1.050909 0 77 2.86025 57 2 17 .9243912 0 23 2.52033 57 2 6 .896088 0 7 2.45 54 2 106 2.683074 0 172 14.63 53 2 25 3.8385315 0 38 46.4571 55 2 53 1.3763703 0 84 3.9605 58 2 102 -.4684049 0 165 .626 56 2 52 2.5971186 0 82 13.425 54 2 95 .4187103 0 151 1.52 55 2 111 1.314249 0 181 3.721954 55 2 35 .13540463 0 55 1.145 54 2 22 2.206967 0 32 9.0881111 58 2 29 2.1494339 0 44 8.58 57 2 75 2.0524557 0 117 7.78700 57 2 50 -.3930426 0 79 .675 55 2 12 1.510722 0 16 4.53 57 2 83 .9038132 0 132 2.469000 55 2 48 1.0598137 0 75 2.8858 55 2 87 -.3047152 0 140 .737333 54 2 36 2.0859354 0 57 8.05212 54 2 45 2.3042505 0 70 10.01666 55 2 38 1.5882143 0 60 4.89500 57 2 104 1.0078211 0 168 2.7396 55 2 110 -1.2039728 1 180 .3 54 2 36 1.1776289 1 58 3.246 54 2 112 2.398777 1 184 11.0 55 2 111 .9341307 1 182 2.545 54 2 56 1.113501 1 89 3.045 55 2 48 2.605894 1 76 13.5433 54 2 95 -.2015044 1 152 .8175 55 2 103 4.2195077 1 167 68 55 2 100 .8754687 1 162 2.4 54 3 112 2.501697 0 183 12.2 55 3 35 2.912799 0 55 18.4 54 3 95 1.041272 0 151 2.8328 55 3 110 2.995732 0 179 20 57 3 81 1.5040774 0 129 4.5 54 3 22 2.2976012 0 32 9.9502 54 3 56 1.907829 0 88 6.73 54 3 114 3.633895 0 186 37.86 57 3 50 -.4764242 0 79 .621 end
Would doing the following be correct for declaring panel data?
Code:
egen panelid = group(countryid pandemic2) xtset panelid bimonth
Thank you in advance
0 Response to DiD Regression with panel data measuring two factors before and after treatment
Post a Comment