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) 1642 21003 1.814742e+12 735 0 0 0 1 0 0 468 21047 1.8184788e+12 118 0 0 0 1 0 0 5679 21377 1.847016e+12 . 0 0 0 0 0 0 4523 20385 1.7613216e+12 650 0 0 0 1 0 0 6792 20315 1.7552916e+12 1042 0 0 0 1 0 0 6974 20577 1.7778744e+12 210 0 0 0 0 0 0 781 20818 1.7986968e+12 21 0 0 0 0 0 0 4865 20756 1.7933508e+12 . 0 0 0 1 0 0 5482 20445 1.7665236e+12 . 0 0 0 0 0 0 1039 20672 1.7861256e+12 . 0 0 0 0 0 0 1586 20067 1.733868e+12 . 0 0 0 1 0 0 6581 19971 1.725552e+12 . 0 0 0 0 0 0 6801 20480 1.7694756e+12 . 0 0 0 0 0 0 4224 21431 1.851696e+12 699 0 0 0 1 0 0 6418 19941 1.7229636e+12 507.6 0 0 0 1 0 0 794 20576 1.77777e+12 46 0 0 0 1 0 0 5808 20583 1.7784108e+12 401 0 0 0 1 0 0 850 19915 1.7207388e+12 . 0 0 0 0 0 0 6277 19983 1.7265456e+12 72 0 0 0 1 0 0 6654 20531 1.773918e+12 . 0 0 0 1 0 0 6014 21367 1.8461376e+12 681 0 0 0 1 0 0 5320 21262 1.8370692e+12 829 0 0 0 0 0 0 1905 21387 1.8479052e+12 714 0 0 0 1 0 0 65 21046 1.8183816e+12 . 0 0 0 1 1 1 6848 21025 1.816578e+12 . 0 0 0 0 0 0 73 21433 1.8518112e+12 1244 0 0 0 1 0 0 5050 20036 1.7311392e+12 . 0 0 0 1 1 1 4319 20398 1.7624268e+12 308 0 0 0 1 0 0 192 20540 1.7747316e+12 538 0 0 0 1 0 0 941 20303 1.7541936e+12 . 0 0 0 0 0 0 1041 20924 1.807902e+12 307 0 0 0 0 0 0 1149 20214 1.7465184e+12 . 0 0 0 0 0 0 6025 19792 1.7100756e+12 . 0 0 0 1 0 0 6641 20328 1.7563608e+12 60 0 0 0 1 0 0 867 21039 1.8177804e+12 71 0 0 0 0 0 0 4599 20780 1.7954604e+12 1160 0 0 0 1 0 0 5501 20540 1.7746776e+12 . 0 0 0 0 0 0 4621 20355 1.7587476e+12 2593 0 0 0 1 0 0 5259 20796 1.7968428e+12 2401 0 0 0 0 0 0 5162 19874 1.717182e+12 . 0 0 0 0 0 0 4953 20462 1.7679852e+12 . 0 0 0 1 0 0 445 19877 1.7174376e+12 1219.2 0 0 0 1 0 0 5094 21360 1.8455184e+12 62 0 0 0 1 0 0 906 21438 1.8522648e+12 123 0 0 0 1 0 0 5315 20788 1.7961552e+12 2325 0 0 0 0 0 0 5558 19799 1.7106516e+12 . 0 0 0 0 0 0 728 20006 1.7285256e+12 47 0 0 0 0 0 0 6924 21374 1.846782e+12 . 0 0 0 1 0 0 4301 20448 1.76679e+12 . 0 0 0 0 0 0 4730 20867 1.8029556e+12 408 0 0 0 0 0 0 6921 20748 1.7926416e+12 . 0 0 0 0 0 0 4537 20638 1.783152e+12 . 0 0 0 1 0 0 6623 21217 1.8332136e+12 . 0 0 0 1 0 0 1479 19900 1.7193744e+12 . 0 0 0 1 0 0 1430 21534 1.860552e+12 10 0 0 0 0 0 0 5630 21209 1.8325404e+12 527 0 0 0 1 0 0 424 20465 1.7682192e+12 . 0 0 0 1 0 0 4753 20063 1.73349e+12 205 0 0 0 1 0 0 6012 20408 1.7633052e+12 . 0 0 0 0 0 0 745 20500 1.7712648e+12 1119 0 0 0 0 0 0 466 21484 1.856268e+12 . 0 0 0 1 0 0 6494 21234 1.8346392e+12 . 0 0 0 0 0 0 974 20814 1.7984124e+12 . 0 0 0 0 0 0 4344 21187 1.8305856e+12 356 0 0 0 1 0 0 1575 20276 1.7518464e+12 . 0 0 0 0 0 0 6407 20794 1.7966016e+12 285 0 0 0 1 0 0 5320 20055 1.7328348e+12 486 0 0 0 0 0 0 732 19935 1.7224344e+12 380 0 0 0 1 0 0 1447 19943 1.7231544e+12 . 0 0 0 0 0 0 5370 20723 1.790532e+12 7710 0 0 0 0 0 0 6614 21618 1.8678024e+12 . 0 0 0 1 1 1 1172 21471 1.8551088e+12 . 0 0 0 0 0 0 5370 21024 1.8165024e+12 6113 0 0 0 0 0 0 916 21219 1.8333684e+12 . 0 0 0 1 0 0 1202 19905 1.7198568e+12 428 0 0 0 0 0 0 6957 20770 1.7945316e+12 . 0 0 0 0 0 0 599 20196 1.744992e+12 . 0 0 0 1 0 0 4573 21620 1.8680328e+12 . 0 0 0 0 0 0 5824 20435 1.7656452e+12 . 0 0 0 1 0 0 4632 20513 1.7723772e+12 . 0 0 0 0 0 0 5310 21594 1.8657612e+12 3614 0 0 0 1 0 0 979 21090 1.8222408e+12 1027 0 0 0 0 0 0 1193 20785 1.79586e+12 216 0 0 0 0 0 0 5351 20068 1.7339292e+12 . 0 0 0 0 0 0 6022 21066 1.8201024e+12 . 0 0 0 1 0 0 6297 19833 1.7136432e+12 1917 0 0 0 0 0 0 1761 19880 1.7176644e+12 . 0 0 0 0 0 0 5873 21161 1.8283824e+12 665 0 0 0 1 0 0 5222 20940 1.809252e+12 168 0 0 0 0 0 0 1326 19822 1.7126604e+12 508 0 0 0 1 0 0 1484 21374 1.8467388e+12 . 0 0 0 0 0 0 4834 21335 1.8433908e+12 . 0 0 0 1 0 0 4932 20445 1.7664912e+12 1498 0 0 0 0 0 0 4010 20210 1.7461728e+12 240 0 0 0 1 0 0 1156 20778 1.7952516e+12 252 0 0 0 0 0 0 5567 21384 1.8475956e+12 72 0 0 0 0 0 0 6795 21348 1.8445428e+12 . 0 0 0 1 0 0 1638 21255 1.8364536e+12 502 0 0 0 1 0 0 1440 20909 1.8065664e+12 . 0 0 0 0 0 0 6373 21188 1.8307224e+12 224 0 0 0 0 0 0 end format %td date_DMY format %tc datetime
0 Response to An event study plot in STATA - multiple, staggered & temporary treatment with spillover effects
Post a Comment