Hi everyone,
I need to build an event-study using a monthly database. I've already done this for annual data, but never with monthly data. I start by sending a data extract:
bigplantopened10_12 is a dummy variable which is set to 1 when an photovoltaic plant of 10MW or more has been installed on a given date in a municipality. I construct the treatment_date_bigplant10 variable as follows:
My aim: I want to do a plotting event-study with a treatment window of -6 (72 months) to 6 (+72 months) years, without plotting the whole months. I don't know how to transform months into years in an event-study and I'm not very sure of the methodology to follow.
I've replicated this code from a published paper, but surely not the best way to do an event-study, I'm aware of that:
Finally, to trace the results, I again follow the code of the article in question, creating a whole mishmash:
I imagine that this is far from the best way to proceed. Could you please help me with this?
Many thanks in advance!
Michael
I need to build an event-study using a monthly database. I've already done this for annual data, but never with monthly data. I start by sending a data extract:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte codauto str22 province long cmunine int(date year) byte sample_new_12 float(bigplantopened10_12 log_unemp log_emp_gen treatment_year_bigplant10) 16 "Araba/Álava" 1047 677 2016 1 0 4.356709 6.45047 -30 16 "Araba/Álava" 1047 678 2016 1 0 4.317488 6.45047 -29 16 "Araba/Álava" 1047 679 2016 1 0 4.276666 6.416732 -28 16 "Araba/Álava" 1047 680 2016 1 0 4.2341065 6.40688 -27 16 "Araba/Álava" 1047 681 2016 1 0 4.276666 6.415097 -26 16 "Araba/Álava" 1047 682 2016 1 0 4.1271343 6.413459 -25 16 "Araba/Álava" 1047 683 2016 1 0 4.189655 6.408529 -24 16 "Araba/Álava" 1047 684 2017 1 0 4.2904596 6.403574 -23 16 "Araba/Álava" 1047 685 2017 1 0 4.276666 6.395262 -22 16 "Araba/Álava" 1047 686 2017 1 0 4.406719 6.369901 -21 16 "Araba/Álava" 1047 687 2017 1 0 4.454347 6.403574 -20 16 "Araba/Álava" 1047 688 2017 1 0 4.3820267 6.410175 -19 16 "Araba/Álava" 1047 689 2017 1 0 4.2341065 6.416732 -18 16 "Araba/Álava" 1047 690 2017 1 0 4.1431346 6.428105 -17 16 "Araba/Álava" 1047 691 2017 1 0 4.1743875 6.431331 -16 16 "Araba/Álava" 1047 692 2017 1 0 4.26268 6.439351 -15 16 "Araba/Álava" 1047 693 2017 1 0 4.189655 6.439351 -14 16 "Araba/Álava" 1047 694 2017 1 0 4.2341065 6.453625 -13 16 "Araba/Álava" 1047 695 2017 1 0 4.204693 6.467699 -12 16 "Araba/Álava" 1047 696 2018 1 0 4.2341065 6.447306 -11 16 "Araba/Álava" 1047 697 2018 1 0 4.1743875 6.444131 -10 16 "Araba/Álava" 1047 698 2018 1 0 4.1271343 6.44572 -9 16 "Araba/Álava" 1047 699 2018 1 0 4.1431346 6.43294 -8 16 "Araba/Álava" 1047 700 2018 1 0 4.158883 6.436151 -7 16 "Araba/Álava" 1047 701 2018 1 0 4.158883 6.429719 -6 16 "Araba/Álava" 1047 702 2018 1 0 4.0775375 6.452049 -5 16 "Araba/Álava" 1047 703 2018 1 0 4.0430512 6.458338 -4 16 "Araba/Álava" 1047 704 2018 1 0 4.0253515 6.461468 -3 16 "Araba/Álava" 1047 705 2018 1 0 4.189655 6.444131 -2 16 "Araba/Álava" 1047 706 2018 1 0 4.158883 6.463029 -1 16 "Araba/Álava" 1047 707 2018 1 1 4.189655 6.464588 0 16 "Araba/Álava" 1047 708 2019 1 1 4.060443 6.464588 1 16 "Araba/Álava" 1047 709 2019 1 1 4.0943446 6.526495 2 16 "Araba/Álava" 1047 710 2019 1 1 4.060443 6.522093 3 16 "Araba/Álava" 1047 711 2019 1 1 3.970292 6.532334 4 16 "Araba/Álava" 1047 712 2019 1 1 3.912023 6.52503 5 16 "Araba/Álava" 1047 713 2019 1 1 3.912023 6.522093 6 16 "Araba/Álava" 1047 714 2019 1 1 3.912023 6.553934 7 16 "Araba/Álava" 1047 715 2019 1 1 3.988984 6.556778 8 16 "Araba/Álava" 1047 716 2019 1 1 4.0253515 6.559615 9 16 "Araba/Álava" 1047 717 2019 1 1 3.9318256 6.559615 10 16 "Araba/Álava" 1047 718 2019 1 1 4.0253515 6.59578 11 16 "Araba/Álava" 1047 719 2019 1 0 4.0073333 6.599871 12 16 "Araba/Álava" 1047 720 2020 1 0 4.1108737 6.620073 13 16 "Araba/Álava" 1047 721 2020 1 0 3.970292 6.622736 14 16 "Araba/Álava" 1047 722 2020 1 0 4.0775375 6.617403 15 16 "Araba/Álava" 1047 723 2020 1 0 4.189655 6.610696 16 16 "Araba/Álava" 1047 724 2020 1 0 4.2195077 6.609349 17 16 "Araba/Álava" 1047 725 2020 1 0 4.317488 6.635947 18 16 "Araba/Álava" 1047 726 2020 1 0 4.3307333 6.648984 19 16 "Araba/Álava" 1047 727 2020 1 0 4.394449 6.647688 20 16 "Araba/Álava" 1047 728 2020 1 0 4.3820267 6.670766 21 16 "Araba/Álava" 1047 729 2020 1 0 4.248495 6.669498 22 16 "Araba/Álava" 1047 730 2020 1 0 4.1271343 6.663133 23 16 "Araba/Álava" 1047 731 2020 1 0 4.158883 6.658011 24 16 "Araba/Álava" 1047 732 2021 1 0 4.189655 6.648984 25 16 "Araba/Álava" 1047 733 2021 1 0 4.158883 6.669498 26 16 "Araba/Álava" 1047 734 2021 1 0 4.189655 6.660575 27 16 "Araba/Álava" 1047 735 2021 1 0 4.204693 6.656726 28 16 "Araba/Álava" 1047 736 2021 1 0 4.1108737 6.652863 29 16 "Araba/Álava" 1047 737 2021 1 0 4.0430512 6.642487 30 end format %tm date
bigplantopened10_12 is a dummy variable which is set to 1 when an photovoltaic plant of 10MW or more has been installed on a given date in a municipality. I construct the treatment_date_bigplant10 variable as follows:
Code:
bys cmunine (date): gen byte D = sum(bigplantopened10_12) == 1 & sum(bigplantopened10_12[_n - 1]) == 0 egen temp = min(date) if D > 0, by(cmunine) egen firstdate_bigplant = max(temp), by(cmunine) format temp firstdate_bigplant %tm gen treatment_date_bigplant10 = date - (firstdate_bigplant) keep if !missing(firstdate_bigplant) // only treated municipalities at
I've replicated this code from a published paper, but surely not the best way to do an event-study, I'm aware of that:
Code:
* Positive // Loop through the values from 1 to 72 (6 years) forvalues i = 1/72 { gen d_bigplant_pos`i' = 0 replace d_bigplant_pos`i' = 1 if (treatment_year_bigplant10 == `i') } // Constant effects from 6 years onwards (> 72 months) gen d_bigplant_pos72 = 0 replace d_bigplant_pos72 = 1 if (treatment_year_bigplant10 > 72) * Negative forvalues i = 1/72 { gen d_bigplant_neg`i' = 0 replace d_bigplant_neg`i' = 1 if (treatment_year_bigplant10 == -`i') } // Constant effects from -6 and less years (< -72 months) gen d_bigplant_neg72 = 0 replace d_bigplant_neg72 = 1 if (treatment_year_bigplant10 < -72) // comunidad autonoma by year fixed effects egen y_ca = group(codauto year) // regressions eststo clear // List of dependent variables local depvars log_unemp log_emp_gen // Loop through each dependent variable foreach depvar in `depvars' { // Run the regression eststo: reghdfe `depvar' d_bigplant_pos72 d_bigplant_pos60 d_bigplant_pos48 d_bigplant_pos36 d_bigplant_pos24 d_bigplant_pos12 /// d_bigplant_neg12 d_bigplant_neg24 d_bigplant_neg36 d_bigplant_neg48 d_bigplant_neg60 /// d_bigplant_pos72, /// absorb(cmunine y_ca) vce(robust) level(90) // Confidence Intervals: 90% } esttab using "es_results_treated_mun10mw_ca_fe.tex", b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) r2 replace
Code:
preserve * ssc install parmest, ssc install dsconcat global tflist "" * Run the regression and store results using parmby tempfile tf1 parmby "reghdfe log_unemp d_bigplant_pos72 d_bigplant_pos60 d_bigplant_pos48 d_bigplant_pos36 d_bigplant_pos24 d_bigplant_pos12 d_bigplant_neg12 d_bigplant_neg24 d_bigplant_neg36 d_bigplant_neg48 d_bigplant_neg60 d_bigplant_pos72, absorb(cmunine y_ca) vce(robust)", level(90) label command format(estimate min90 max90 %8.2f p %8.1e) idn(1) saving(`tf1', replace) flist(tflist) tempfile tf2 parmby "reghdfe log_emp_gen d_bigplant_pos72 d_bigplant_pos60 d_bigplant_pos48 d_bigplant_pos36 d_bigplant_pos24 d_bigplant_pos12 d_bigplant_neg12 d_bigplant_neg24 d_bigplant_neg36 d_bigplant_neg48 d_bigplant_neg60 d_bigplant_pos72, absorb(cmunine y_ca) vce(robust)", level(90) label command format(estimate min90 max90 %8.2f p %8.1e) idn(2) saving(`tf2', replace) flist(tflist) * Combine all regression outcomes into one dataset dsconcat $tflist keep if regexm(parm, "bigplant") == 1
I imagine that this is far from the best way to proceed. Could you please help me with this?
Many thanks in advance!
Michael