Hello!
Disclaimer - Apologies for any inconsistency in the posting format, I have read instructions/FAQ but this is still my first post so fear I may have violated any standards!
I am looking to produce an event study plot to check for parallel trends in a generalised DD analysis. The project looks at how a congestion policy impacts to traffic. The policy is introduced in certain zones and is only operational for certain hours of the day and certain days of the week. For example, district A is only affected on Saturdays & Sundays from 9am-5pm while district C is affected on Saturdays for 24 hours. District B (neighboring to district A) has spillover effects from the policy, even though they are not included as part of the congestion policy. In a sense, district B is also being "treated" by the policy but to a different intensity. This naturally leads me to ask if an event study would suit this setup to show parallel trends, as the "control" group is also being treated?
If an event study does suit, I have been struggling with using esplot and event_plot. I believe both commands are designed to plot event studies. I believe both require a balanced panel, which (in theory) I do not have. I have a dataset that is unique by road sensor ID and date-time (DDMMYYY hh:mm:ss), see below for example. Even though I have imputed the hours/days for which we do not have traffic measurements, I cannot force these values to be 0 and they remain missing (we cannot say for sure that there were no cars on road ABC). Due to these missing values, event_plot nor esplot seem to not recognize the dataset to be balanced. Is there a possible solution to produce an event study plot?
Fine Details: I am using Stata MP 15. Hourly analysis has 72 million observations & daily analysis is at 3.4 million observations. Example of the hourly dataset below. The daily dataset is the below dataset collapsed by date_DMY. iu_ac is the unique identifier for each road sensor. debit is the number of cars.
Disclaimer - Apologies for any inconsistency in the posting format, I have read instructions/FAQ but this is still my first post so fear I may have violated any standards!
I am looking to produce an event study plot to check for parallel trends in a generalised DD analysis. The project looks at how a congestion policy impacts to traffic. The policy is introduced in certain zones and is only operational for certain hours of the day and certain days of the week. For example, district A is only affected on Saturdays & Sundays from 9am-5pm while district C is affected on Saturdays for 24 hours. District B (neighboring to district A) has spillover effects from the policy, even though they are not included as part of the congestion policy. In a sense, district B is also being "treated" by the policy but to a different intensity. This naturally leads me to ask if an event study would suit this setup to show parallel trends, as the "control" group is also being treated?
If an event study does suit, I have been struggling with using esplot and event_plot. I believe both commands are designed to plot event studies. I believe both require a balanced panel, which (in theory) I do not have. I have a dataset that is unique by road sensor ID and date-time (DDMMYYY hh:mm:ss), see below for example. Even though I have imputed the hours/days for which we do not have traffic measurements, I cannot force these values to be 0 and they remain missing (we cannot say for sure that there were no cars on road ABC). Due to these missing values, event_plot nor esplot seem to not recognize the dataset to be balanced. Is there a possible solution to produce an event study plot?
Code:
*attempt with esplot* esplot debit, event(PolicyDay) esplot debit, event(PolicyDay) compare(PolicyZone) *attempt with event_plot* ppmlhdfe debit l(0/7).PolicyDay f(0/7).PolicyDay /// poisson for count variable i.Annual_CFDay c.mean_rain c.mean_avetemp, /// controls for car-free day, and weather absorb(i.date_dow i.date_MM i.date_YYYY i.holiday i.iu_ac) /// time-fixed effects and road sensor FE irr vce(cluster i.iu_ac#date_dow) // clustering two-ways (road sensor and day of week) event_plot, default_look stub_lag(L#event) stub_lead(F#event) together plottype(scatter)
Fine Details: I am using Stata MP 15. Hourly analysis has 72 million observations & daily analysis is at 3.4 million observations. Example of the hourly dataset below. The daily dataset is the below dataset collapsed by date_DMY. iu_ac is the unique identifier for each road sensor. debit is the number of cars.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int(iu_ac date_DMY) double(datetime debit) byte(PolicyZone PolicyDay PolicyHour) float(PolicyZone_Buffer5 PolicyDayB3 PolicyHourB3) byte Annual_CFDay float(mean_rain mean_temperature) 1642 21003 1.814742e+12 735 0 0 0 1 0 0 0 0 24.325 468 21047 1.8184788e+12 118 0 0 0 1 0 0 0 .225 26.35 5679 21377 1.847016e+12 . 0 0 0 0 0 0 0 0 25.675 4523 20385 1.7613216e+12 650 0 0 0 1 0 0 0 0 15.325 6792 20315 1.7552916e+12 1042 0 0 0 1 0 0 0 .1 21.025 6974 20577 1.7778744e+12 210 0 0 0 0 0 0 0 0 16.5 781 20818 1.7986968e+12 21 0 0 0 0 0 0 0 .01111111 .475 4865 20756 1.7933508e+12 . 0 0 0 1 0 0 0 .07777778 13.975 5482 20445 1.7665236e+12 . 0 0 0 0 0 0 0 .01111111 13.325 1039 20672 1.7861256e+12 . 0 0 0 0 0 0 0 0 24.85 1586 20067 1.733868e+12 . 0 0 0 1 0 0 0 .4222222 10.3 6581 19971 1.725552e+12 . 0 0 0 0 0 0 0 0 23.65 6801 20480 1.7694756e+12 . 0 0 0 0 0 0 0 1.6666666 12 4224 21431 1.851696e+12 699 0 0 0 1 0 0 0 .01111111 19.75 6418 19941 1.7229636e+12 507.6 0 0 0 1 0 0 0 22.41111 23.25 794 20576 1.77777e+12 46 0 0 0 1 0 0 0 .4 18.725 5808 20583 1.7784108e+12 401 0 0 0 1 0 0 0 4.366667 21.375 850 19915 1.7207388e+12 . 0 0 0 0 0 0 0 2.625 19.85 6277 19983 1.7265456e+12 72 0 0 0 1 0 0 0 .025 26.74 6654 20531 1.773918e+12 . 0 0 0 1 0 0 0 0 10.575 6014 21367 1.8461376e+12 681 0 0 0 1 0 0 0 .04444445 31 5320 21262 1.8370692e+12 829 0 0 0 0 0 0 0 .23333333 1.1750001 1905 21387 1.8479052e+12 714 0 0 0 1 0 0 0 0 27.9 65 21046 1.8183816e+12 . 0 0 0 1 1 1 0 .275 26.7 6848 21025 1.816578e+12 . 0 0 0 0 0 0 0 .22222222 22 73 21433 1.8518112e+12 1244 0 0 0 1 0 0 0 .22222222 21.4 5050 20036 1.7311392e+12 . 0 0 0 1 1 1 0 .05555556 13.34 4319 20398 1.7624268e+12 308 0 0 0 1 0 0 0 1.1555556 18.275 192 20540 1.7747316e+12 538 0 0 0 1 0 0 0 1.7555555 12.8 941 20303 1.7541936e+12 . 0 0 0 0 0 0 0 1.2714286 32.925 1041 20924 1.807902e+12 307 0 0 0 0 0 0 0 .8111112 15.05 1149 20214 1.7465184e+12 . 0 0 0 0 0 0 0 1.1777778 16.775 6025 19792 1.7100756e+12 . 0 0 0 1 0 0 0 0 20.03333 6641 20328 1.7563608e+12 60 0 0 0 1 0 0 0 0 23.525 867 21039 1.8177804e+12 71 0 0 0 0 0 0 0 4.5 19.075 4599 20780 1.7954604e+12 1160 0 0 0 1 0 0 0 6.425 11.775 5501 20540 1.7746776e+12 . 0 0 0 0 0 0 0 1.7555555 12.8 4621 20355 1.7587476e+12 2593 0 0 0 1 0 0 0 2.0777779 17.574999 5259 20796 1.7968428e+12 2401 0 0 0 0 0 0 0 .06666667 10.425 5162 19874 1.717182e+12 . 0 0 0 0 0 0 0 0 20.975 4953 20462 1.7679852e+12 . 0 0 0 1 0 0 0 3.6444445 11.175 445 19877 1.7174376e+12 1219.2 0 0 0 1 0 0 0 8.2 20.8 5094 21360 1.8455184e+12 62 0 0 0 1 0 0 0 0 25.075 906 21438 1.8522648e+12 123 0 0 0 1 0 0 0 0 29.625 5315 20788 1.7961552e+12 2325 0 0 0 0 0 0 0 0 6.775 5558 19799 1.7106516e+12 . 0 0 0 0 0 0 0 0 12.15 728 20006 1.7285256e+12 47 0 0 0 0 0 0 0 6.1 17.866667 6924 21374 1.846782e+12 . 0 0 0 1 0 0 0 0 26.85 4301 20448 1.76679e+12 . 0 0 0 0 0 0 0 .02222222 13.475 4730 20867 1.8029556e+12 408 0 0 0 0 0 0 0 0 10.55 6921 20748 1.7926416e+12 . 0 0 0 0 0 0 0 1.5333333 13.525 4537 20638 1.783152e+12 . 0 0 0 1 0 0 0 2.733333 17.85 6623 21217 1.8332136e+12 . 0 0 0 1 0 0 0 .5625 6.475 1479 19900 1.7193744e+12 . 0 0 0 1 0 0 0 .4 25.666666 1430 21534 1.860552e+12 10 0 0 0 0 0 0 0 2.3111112 7.6 5630 21209 1.8325404e+12 527 0 0 0 1 0 0 0 1.6 8.475 424 20465 1.7682192e+12 . 0 0 0 1 0 0 0 .4777778 8 4753 20063 1.73349e+12 205 0 0 0 1 0 0 0 0 8.725 6012 20408 1.7633052e+12 . 0 0 0 0 0 0 0 1.411111 15.35 745 20500 1.7712648e+12 1119 0 0 0 0 0 0 0 .0375 5.85 466 21484 1.856268e+12 . 0 0 0 1 0 0 0 0 9.925 6494 21234 1.8346392e+12 . 0 0 0 0 0 0 0 3.4 5.7 974 20814 1.7984124e+12 . 0 0 0 0 0 0 0 .13333334 11.625 4344 21187 1.8305856e+12 356 0 0 0 1 0 0 0 9 11.425 1575 20276 1.7518464e+12 . 0 0 0 0 0 0 0 .725 26.975 6407 20794 1.7966016e+12 285 0 0 0 1 0 0 0 .02222222 11.2 5320 20055 1.7328348e+12 486 0 0 0 0 0 0 0 .1 15.1 732 19935 1.7224344e+12 380 0 0 0 1 0 0 0 0 27.21667 1447 19943 1.7231544e+12 . 0 0 0 0 0 0 0 5.244444 22.6 5370 20723 1.790532e+12 7710 0 0 0 0 0 0 0 0 20.825 6614 21618 1.8678024e+12 . 0 0 0 1 1 1 0 1.75 13.55 1172 21471 1.8551088e+12 . 0 0 0 0 0 0 0 0 26.075 5370 21024 1.8165024e+12 6113 0 0 0 0 0 0 0 2.788889 20.125 916 21219 1.8333684e+12 . 0 0 0 1 0 0 0 0 3.225 1202 19905 1.7198568e+12 428 0 0 0 0 0 0 0 0 23.42 6957 20770 1.7945316e+12 . 0 0 0 0 0 0 0 3.9375 6.875 599 20196 1.744992e+12 . 0 0 0 1 0 0 0 0 16.75 4573 21620 1.8680328e+12 . 0 0 0 0 0 0 0 2.3375 12.425 5824 20435 1.7656452e+12 . 0 0 0 1 0 0 0 .02222222 7.575 4632 20513 1.7723772e+12 . 0 0 0 0 0 0 0 0 7.5 5310 21594 1.8657612e+12 3614 0 0 0 1 0 0 0 0 13.65 979 21090 1.8222408e+12 1027 0 0 0 0 0 0 0 .23333333 20.1 1193 20785 1.79586e+12 216 0 0 0 0 0 0 0 .0375 9.5 5351 20068 1.7339292e+12 . 0 0 0 0 0 0 0 .3222222 10.48 6022 21066 1.8201024e+12 . 0 0 0 1 0 0 0 .02222222 24.25 6297 19833 1.7136432e+12 1917 0 0 0 0 0 0 0 0 18.525 1761 19880 1.7176644e+12 . 0 0 0 0 0 0 0 0 28.075 5873 21161 1.8283824e+12 665 0 0 0 1 0 0 0 2.2444444 4.75 5222 20940 1.809252e+12 168 0 0 0 0 0 0 0 0 15.975 1326 19822 1.7126604e+12 508 0 0 0 1 0 0 0 0 17.54 1484 21374 1.8467388e+12 . 0 0 0 0 0 0 0 0 26.85 4834 21335 1.8433908e+12 . 0 0 0 1 0 0 0 0 25.775 4932 20445 1.7664912e+12 1498 0 0 0 0 0 0 0 .01111111 13.325 4010 20210 1.7461728e+12 240 0 0 0 1 0 0 0 5.144444 14.275 1156 20778 1.7952516e+12 252 0 0 0 0 0 0 0 7.025 13.375 5567 21384 1.8475956e+12 72 0 0 0 0 0 0 0 .44444445 30.375 6795 21348 1.8445428e+12 . 0 0 0 1 0 0 0 .05555556 18.224998 1638 21255 1.8364536e+12 502 0 0 0 1 0 0 0 1.888889 12.675 1440 20909 1.8065664e+12 . 0 0 0 0 0 0 0 1.875 18.15 6373 21188 1.8307224e+12 224 0 0 0 0 0 0 0 6.244444 13.85 end format %td date_DMY format %tc datetime
Comment