I'm trying to run a couple of fixed effect regressions with my data.
I want to understand whether the absenteeism rates for employees across a large number of factories with separate units is dependent on the few vaccination drives that took place across these units.
My outcome of interests (at the employee level) are absenteeism which is a % for each individual employee, who are part of a specific unit within a factory for each week of the years 2020 and 2021.
My Independent variables (at the unit level) are:
i) 'Cumulative frequency of vaccine drives' - this variables is the cumulative number of "vaccine camps" (a day in which > 1 person was vaccinated in the unit) a unit has had as of week t
I estimated y fixed effects model like this:
Code:
foreach fe in "factory week year" "empcode week year" { eststo: reghdfe absent cumfreq_frac, a(`fe') vce(cluster factory)
Code:
bysort factory:gen cumfreqlead1 = cumfreq[_n+1] bysort factory:gen cumfreqlead2 = cumfreq[_n+2] bysort factory:gen cumfreqlead3 = cumfreq[_n+3] bysort factory:gen cumfreqlead4 = cumfreq[_n+4] local leads0 "cumfreq" local leads1 "cumfreq cumfreqlead1" local leads2 "cumfreq cumfreqlead1 cumfreqlead2" local leads3 "cumfreq cumfreqlead1 cumfreqlead2 cumfreqlead3" local leads4 "cumfreq cumfreqlead1 cumfreqlead2 cumfreqlead3 cumfreqlead4" foreach fe in "factory week year" "empcode week year" { forvalues i= 0/4 { eststo: reghdfe absent `leads`i', a(`fe') vce(cluster factory)
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str11 factory long empcode float(week cumfreq absent year) "A39" 20266278 1 0 0 2020 "A39" 20026506 2 0 0 2020 "A39" 20324630 3 0 0 2020 "A39" 20228504 4 0 0 2020 "A39" 20027582 5 0 0 2020 "A39" 20358281 6 0 0 2020 "A39" 20235109 7 0 0 2021 "A39" 20042016 8 0 0 2020 "A39" 20278393 9 0 0 2020 "A39" 20026593 10 0 0 2021 "A39" 20459275 11 0 . 2021 "A39" 20359700 12 0 0 2020 "A39" 20240917 13 0 0 2020 "A39" 20236972 14 0 0 2020 "A39" 20277885 15 0 .2 2021 "A39" 20028122 16 0 0 2021 "A39" 20025408 17 0 .5 2021 "A39" 20472340 18 0 1 2021 "A39" 20295460 19 0 .3333333 2020 "A39" 20234968 20 0 0 2020 "A39" 20038451 21 0 . 2021 "A39" 20084114 22 0 0 2020 "A39" 20354841 23 0 1 2021 "A39" 20029917 24 0 .8333333 2021 "A39" 20311707 25 3 0 2020 "A39" 20085729 26 5 0 2020 "A39" 20027444 27 5 0 2020 "A39" 20051129 28 5 1 2020 "A39" 20465345 29 5 . 2021 "A39" 20047686 30 5 0 2021 "A39" 20025267 31 5 0 2020 "A39" 20081528 32 5 0 2020 "A39" 20042390 33 6 .16666667 2021 "A39" 20500614 34 7 . 2021 "A39" 20475982 35 7 0 2021 "A39" 20443160 36 7 .14285715 2021 "A39" 20228508 37 7 0 2021 "A39" 20038397 38 7 0 2021 "A39" 20030431 39 7 0 2020 "A39" 20495736 40 7 0 2021 "A39" 20235109 41 7 0 2020 "A39" 20027149 42 7 0 2020 "A39" 20025264 43 7 0 2021 "A39" 20028376 44 7 0 2020 "A39" 20065916 45 7 0 2020 "A39" 20135734 46 7 0 2020 "A39" 20085520 47 7 0 2020 "A39" 20027316 48 7 0 2020 "A39" 20097063 49 7 0 2020 "A39" 20193865 50 7 . 2020 "A39" 20430533 51 7 .6666667 2020 "A39" 20036761 52 7 .25 2020 "B01" 20437744 1 0 .3333333 2021 "B01" 20346050 2 0 0 2020 "B01" 20299781 3 0 0 2020 "B01" 20306242 4 0 0 2020 "B01" 20006143 5 0 0 2020 "B01" 20316064 6 0 0 2020 "B01" 20461260 7 0 0 2021 "B01" 20346260 8 0 .2 2020 "B01" 20393342 9 0 . 2021 "B01" 20420972 10 0 .6666667 2021 "B01" 20348414 11 0 0 2020 "B01" 20392137 12 0 0 2020 "B01" 20443215 13 0 0 2021 "B01" 20412907 14 0 0 2021 "B01" 20117882 15 0 0 2021 "B01" 20474158 16 1 0 2021 "B01" 20427971 17 1 0 2021 "B01" 20267317 18 1 .4285714 2020 "B01" 20022638 19 1 1 2020 "B01" 20407284 20 1 . 2021 "B01" 20472276 21 1 . 2021 "B01" 20065457 22 1 0 2020 "B01" 20342939 23 2 0 2020 "B01" 20024242 24 4 0 2020 "B01" 20065429 25 8 0 2021 "B01" 20320991 26 10 0 2020 "B01" 20436381 27 10 0 2021 "B01" 20478919 28 11 0 2021 "B01" 20011277 29 11 0 2020 "B01" 20350288 30 11 0 2021 "B01" 20320180 31 11 .16666667 2020 "B01" 20465067 32 11 .6666667 2021 "B01" 20500746 33 11 0 2021 "B01" 20480324 34 11 0 2021 "B01" 20479168 35 12 0 2021 "B01" 20024244 36 12 0 2021 "B01" 20181704 37 12 .25 2021 "B01" 20039888 38 12 0 2020 "B01" 20421442 39 12 0 2020 "B01" 20259341 40 12 0 2020 "B01" 20428252 41 12 0 2021 "B01" 20522630 42 12 0 2021 "B01" 20420966 43 12 .25 2020 "B01" 20185107 44 12 0 2021 "B01" 20386628 45 12 0 2020 "B01" 20306744 46 12 0 2020 "B01" 20384885 47 12 0 2020 "B01" 20379506 48 12 0 2020 end
0 Response to Creating a lead variable for fixed effect regressions
Post a Comment