I have a 7 year state panel of US states:
Code:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float medicaidexp byte(ys_Covid_1 ys_Covid_2 ys_Covid_3 ys_Covid_4 ys_Covid_5 ys_Covid_6 ys_Covid_7) float(female educ race marstat age pweightnorm) long stateid 1 1 0 0 0 0 0 0 0 5 1 1 57 .005767725 7 1 1 0 0 0 0 0 0 1 3 1 1 52 .0021913077 7 0 1 0 0 0 0 0 0 1 2 1 2 72 .0140693 34 0 1 0 0 0 0 0 0 1 2 1 1 48 .006607443 44 1 1 0 0 0 0 0 0 0 5 1 1 44 .002757298 7 1 1 0 0 0 0 0 0 0 4 2 5 37 .007216116 7 1 1 0 0 0 0 0 0 1 1 4 2 85 .001290578 12 1 1 0 0 0 0 0 0 0 4 1 5 20 .003079117 7 1 1 0 0 0 0 0 0 0 4 1 1 31 .002778598 7 1 1 0 0 0 0 0 0 1 3 1 5 60 .0100755 15 1 1 0 0 0 0 0 0 0 5 1 1 33 .005290445 7 1 1 0 0 0 0 0 0 1 4 3 3 52 .009107112 5 1 1 0 0 0 0 0 0 1 5 4 1 43 .00296828 7 1 1 0 0 0 0 0 0 0 5 1 1 46 .004987491 7 1 1 0 0 0 0 0 0 1 5 1 1 30 .0024930646 8 1 1 0 0 0 0 0 0 0 3 1 4 57 .01188893 5 1 1 0 0 0 0 0 0 1 5 1 1 26 .00293571 4 0 1 0 0 0 0 0 0 1 5 1 5 29 .007599649 37 1 1 0 0 0 0 0 0 0 5 1 1 54 .011004836 7 1 1 0 0 0 0 0 0 1 2 2 2 76 .004924622 7 1 1 0 0 0 0 0 0 1 4 1 1 74 .004693578 7 1 1 0 0 0 0 0 0 0 2 1 1 41 .006434521 22 0 1 0 0 0 0 0 0 0 4 3 5 24 .01271486 44 1 1 0 0 0 0 0 0 1 5 4 1 62 .007361092 7 1 1 0 0 0 0 0 0 0 5 1 1 52 .006293715 5 1 1 0 0 0 0 0 0 0 5 1 1 39 .003365105 47 1 1 0 0 0 0 0 0 0 5 1 1 44 .002735502 7 1 1 0 0 0 0 0 0 1 3 1 3 69 .004855973 7 1 1 0 0 0 0 0 0 1 4 1 5 23 .006052185 7 0 1 0 0 0 0 0 0 1 4 3 5 39 .009347362 10 0 1 0 0 0 0 0 0 0 5 4 1 44 .004551162 50 1 1 0 0 0 0 0 0 1 4 1 1 57 .004958554 7 1 1 0 0 0 0 0 0 0 3 1 1 42 .0040320656 21 1 1 0 0 0 0 0 0 0 4 3 1 69 .003825088 6 1 1 0 0 0 0 0 0 0 4 1 1 46 .009287671 3 1 1 0 0 0 0 0 0 0 4 2 5 22 .005037605 38 1 1 0 0 0 0 0 0 0 3 1 1 25 .0009790378 35 1 1 0 0 0 0 0 0 1 5 1 3 63 .013293606 33 1 1 0 0 0 0 0 0 1 5 1 1 55 .005035913 38 1 1 0 0 0 0 0 0 0 3 2 1 30 .002743841 7 1 1 0 0 0 0 0 0 1 2 1 2 85 .013044688 14 1 1 0 0 0 0 0 0 1 3 1 1 80 .002370339 4 1 1 0 0 0 0 0 0 0 1 2 4 67 .006440259 22 1 1 0 0 0 0 0 0 1 3 1 1 34 .0010463656 2 1 1 0 0 0 0 0 0 0 5 1 1 48 .002517213 7 1 1 0 0 0 0 0 0 1 4 1 1 36 .004957192 7 1 1 0 0 0 0 0 0 1 5 1 1 30 .00049143843 9 1 1 0 0 0 0 0 0 1 5 1 3 51 .005935569 48 1 1 0 0 0 0 0 0 1 4 1 5 48 .00260902 7 1 1 0 0 0 0 0 0 0 4 2 5 25 .014759748 7 0 1 0 0 0 0 0 0 0 5 3 3 49 .007714862 43 1 1 0 0 0 0 0 0 1 4 1 1 74 .0022333309 20 1 1 0 0 0 0 0 0 0 5 1 1 59 .0044080853 7 1 1 0 0 0 0 0 0 0 4 1 1 44 .002791973 7 0 1 0 0 0 0 0 0 0 3 2 1 40 .006291857 44 1 1 0 0 0 0 0 0 0 4 3 1 58 .005130031 21 1 1 0 0 0 0 0 0 1 5 4 1 35 .003651505 7 1 1 0 0 0 0 0 0 0 5 1 1 47 .0062526 45 1 1 0 0 0 0 0 0 1 3 1 3 36 .005249909 7 1 1 0 0 0 0 0 0 1 5 1 3 56 .012940952 14 1 1 0 0 0 0 0 0 1 5 1 1 30 .0017661237 13 1 1 0 0 0 0 0 0 1 2 1 3 56 .004976222 38 1 1 0 0 0 0 0 0 0 5 2 1 54 .002468668 7 1 1 0 0 0 0 0 0 1 1 2 5 49 .0023114325 7 0 1 0 0 0 0 0 0 1 4 2 3 32 .006442735 10 1 1 0 0 0 0 0 0 1 5 4 3 61 .008046505 31 1 1 0 0 0 0 0 0 0 4 1 5 20 .003701 7 1 1 0 0 0 0 0 0 1 5 1 3 49 .013174349 36 1 1 0 0 0 0 0 0 1 4 1 3 55 .006033279 7 0 1 0 0 0 0 0 0 1 2 1 2 80 .004426455 50 1 1 0 0 0 0 0 0 0 1 1 1 51 .003003533 7 1 1 0 0 0 0 0 0 0 5 1 3 52 .004732835 7 1 1 0 0 0 0 0 0 1 2 1 2 80 .004711287 7 1 1 0 0 0 0 0 0 0 5 2 1 59 .006170742 47 1 1 0 0 0 0 0 0 1 5 1 3 39 .0028156266 7 1 1 0 0 0 0 0 0 0 3 2 1 31 .002422847 7 1 1 0 0 0 0 0 0 0 3 1 1 46 .006045292 7 1 1 0 0 0 0 0 0 0 2 3 1 61 .0030125736 4 1 1 0 0 0 0 0 0 0 3 1 1 55 .0014200322 46 1 1 0 0 0 0 0 0 0 5 2 1 39 .0020772512 7 1 1 0 0 0 0 0 0 0 3 1 1 59 .0043204892 7 1 1 0 0 0 0 0 0 1 5 1 3 59 .002908548 32 1 1 0 0 0 0 0 0 1 4 1 2 34 .0029711695 6 1 1 0 0 0 0 0 0 1 5 2 1 55 .002632013 7 1 1 0 0 0 0 0 0 1 5 1 3 60 .006124467 19 1 1 0 0 0 0 0 0 1 3 1 2 80 .004786664 7 0 1 0 0 0 0 0 0 1 5 1 1 48 .015671747 10 1 1 0 0 0 0 0 0 0 5 1 1 58 .010713895 7 1 1 0 0 0 0 0 0 1 3 3 5 23 .003912271 7 1 1 0 0 0 0 0 0 1 3 4 1 38 .0012618472 8 1 1 0 0 0 0 0 0 1 1 3 4 58 .0032163316 7 1 1 0 0 0 0 0 0 1 4 1 2 85 .009851102 7 0 1 0 0 0 0 0 0 1 3 3 1 35 .006111628 41 1 1 0 0 0 0 0 0 0 4 1 1 54 .010432613 18 1 1 0 0 0 0 0 0 0 3 3 1 48 .008196558 47 1 1 0 0 0 0 0 0 0 4 4 5 24 .0045837318 20 1 1 0 0 0 0 0 0 0 4 1 1 44 .0017162162 13 1 1 0 0 0 0 0 0 0 5 1 1 44 .005988284 7 1 1 0 0 0 0 0 0 1 3 1 2 85 .0044194786 7 0 1 0 0 0 0 0 0 1 4 2 5 32 .006085292 10 end label values educ neweduc label def neweduc 1 "Less HS", modify label def neweduc 2 "Some HS", modify label def neweduc 3 "HS grad", modify label def neweduc 4 "Some college or Associate's degree", modify label def neweduc 5 "Bachelor's or graduate degree", modify label values race newrace label def newrace 1 "White Non-Hispanice", modify label def newrace 2 "Hispanic", modify label def newrace 3 "Black Non-Hispanice", modify label def newrace 4 "Asian Non-Hispanice", modify label values marstat newmarstat label def newmarstat 1 "Now married", modify label def newmarstat 2 "Widowed", modify label def newmarstat 3 "Divorced", modify label def newmarstat 4 "Separated", modify label def newmarstat 5 "Never married", modify label values stateid stateid label def stateid 2 "02", modify label def stateid 3 "04", modify label def stateid 4 "05", modify label def stateid 5 "06", modify label def stateid 6 "08", modify label def stateid 7 "09", modify label def stateid 8 "10", modify label def stateid 9 "11", modify label def stateid 10 "12", modify label def stateid 12 "15", modify label def stateid 13 "16", modify label def stateid 14 "17", modify label def stateid 15 "18", modify label def stateid 18 "21", modify label def stateid 19 "22", modify label def stateid 20 "23", modify label def stateid 21 "24", modify label def stateid 22 "25", modify label def stateid 31 "34", modify label def stateid 32 "35", modify label def stateid 33 "36", modify label def stateid 34 "37", modify label def stateid 35 "38", modify label def stateid 36 "39", modify label def stateid 37 "40", modify label def stateid 38 "41", modify label def stateid 41 "45", modify label def stateid 43 "47", modify label def stateid 44 "48", modify label def stateid 45 "49", modify label def stateid 46 "50", modify label def stateid 47 "51", modify label def stateid 48 "53", modify label def stateid 50 "55", modify
Code:
*Fit the event study regressions . foreach O in medicaid anycov privins { 2. foreach T in Covid{ 3. gen b_`O'`T' = . 4. gen upper_`O'`T' = . 5. gen lower_`O'`T' = . 6. gen br_`O'`T' = . 7. gen upperr_`O'`T' = . 8. gen lowerr_`O'`T' = . 9. gen bi_`O'`T' = . 10. gen upperi_`O'`T' = . 11. gen loweri_`O'`T' = . 12. . . . reghdfe `O' medicaidexp##(ys_`T'_1-ys_`T'_5 ys_`T'_7) female i.educ i.race i.marstat c.age##c.ag > e [pweight=pweightnorm], /// > absorb(stateid /*year*/, save) cluster(stateid) 13. . estimates store c`O'`T' 14. . local row = 0 15. . forvalues t = 1(1)5 { 16. local ++row 17. qui replace b_`O'`T' = _b[1.ys_`T'_`t'] in `row' 18. qui replace upper_`O'`T' = _b[1.ys_`T'_`t'] + 1.96*_se[1.ys_`T'_`t'] in `row' 19. qui replace lower_`O'`T' = _b[1.ys_`T'_`t']- 1.96*_se[1.ys_`T'_`t'] in `row' 20. qui replace br_`O'`T' = _b[1.medicaidexp#1.ys_`T'_`t'] in `row' 21. qui replace upperr_`O'`T' = _b[1.medicaidexp#1.ys_`T'_`t'] + 1.96*_se[1.medicaidexp#1.ys_`T'_ > `t'] in `row' 22. qui replace lowerr_`O'`T' = _b[1.medicaidexp#1.ys_`T'_`t']- 1.96*_se[1.medicaidexp#1.ys_`T'_ > `t'] in `row' 23. } 24. local ++row 25. qui replace b_`O'`T'= 0 in `row' 26. qui replace br_`O'`T'= 0 in `row' 27. forvalues t = 7 { 28. local ++row 29. qui replace b_`O'`T' = _b[1.ys_`T'_`t'] in `row' 30. qui replace upper_`O'`T' = _b[1.ys_`T'_`t'] + 1.96*_se[1.ys_`T'_`t'] in `row' 31. qui replace lower_`O'`T' = _b[1.ys_`T'_`t'] - 1.96*_se[1.ys_`T'_`t'] in `row' 32. qui replace br_`O'`T' = _b[1.medicaidexp#1.ys_`T'_`t'] in `row' 33. qui replace upperr_`O'`T' = _b[1.medicaidexp#1.ys_`T'_`t'] + 1.96*_se[1.medicaidexp#1.ys_`T'_ > `t'] in `row' 34. qui replace lowerr_`O'`T' = _b[1.medicaidexp#1.ys_`T'_`t'] - 1.96*_se[1.medicaidexp#1.ys_`T'_ > `t'] in `row' 35. } 36. . . . local ys 1 2 3 4 5 7 37. foreach y of local ys{ 38. qui reghdfe `O' medicaidexp##(ys_`T'_1-ys_`T'_5 ys_`T'_7), /// > absorb(county_d date state_d##date, save) cluster(county_d) 39. margins, expression(_b[1.ys_`T'_`y']+_b[1.medicaidexp#1.ys_`T'_`y']) post 40. /*qui*/ esttab, ci 41. mat ci`O'`T'`y'= r(coefs) 42. } 43. mat ci`O'`T'6=(0,0,0,0) 44. mat ci`O'`T' = ci`O'`T'1\ci`O'`T'2\ci`O'`T'3\ci`O'`T'4\ci`O'`T'5\ci`O'`T'6\ci`O'`T'7 45. mat list ci`O'`T' 46. . . local row3 = 0 47. forvalues ti = 1(1)5 { 48. local ++row3 49. qui replace bi_`O'`T' = ci`O'`T'[`ti',1] in `row3' 50. qui replace upperi_`O'`T' = ci`O'`T'[`ti',2] in `row3' 51. qui replace loweri_`O'`T' = ci`O'`T'[`ti',3] in `row3' 52. } 53. local ++row3 54. qui replace bi_`O'`T'= 0 in `row3' 55. forvalues ti = 7 { 56. local ++row3 57. qui replace bi_`O'`T' = ci`O'`T'[`ti',1] in `row3' 58. qui replace upperi_`O'`T' = ci`O'`T'[`ti',2] in `row3' 59. qui replace loweri_`O'`T' = ci`O'`T'[`ti',3] in `row3' 60. } 61. . . # delimit ; delimiter now ; . twoway > (rarea upper_`O'`T' lower_`O'`T' timeG if inrange(timeG, -6,0), color(gs12%35)) > (connected b_`O'`T' timeG if inrange(timeG, -6,-2), > mcolor(cranberry) lwidth(medium) lcolor(cranberry) msize(small)) > (connected b_`O'`T' timeG if inrange(timeG, 0,0), > mcolor(cranberry) lwidth(medium) lcolor(cranberry) msize(small)) > (function y = 0, range(-6 0) lcolor(gs10)), > xline(-.5 , lwidth(2.2) lcolor(gs10) ) > xsize(4) ysize(2) > xtitle("") ytitle("`Label`O''", size(vsmall)) > graphregion(color(white)) > xlabel(-6(1)0, labsize(small)) > ylabel(/*-400(150)200*/, labsize(small) ) > legend(off) > graphregion(margin(r+5)) > title("Non-Medicaid Exp. States - `Title`T'':" "`Title`O''", pos(11) size(3.5)) > name(`O'`T', replace) > ; 62. # delimit cr delimiter now cr . graph export "$plotdir/ES_`O'`T'.png", replace width(4000) 63. . # delimit ; delimiter now ; . twoway > (rarea upperr_`O'`T' lowerr_`O'`T' timeG if inrange(timeG, -6,0), color(gs12%35)) > (connected br_`O'`T' timeG if inrange(timeG, -6,-2), > mcolor(cranberry) lwidth(medium) lcolor(cranberry) msize(small)) > (connected br_`O'`T' timeG if inrange(timeG, 0,0), > mcolor(cranberry) lwidth(medium) lcolor(cranberry) msize(small)) > (function y = 0, range(-6 0) lcolor(gs10)), > xline(-.5 , lwidth(2.2) lcolor(gs10) ) > xsize(4) ysize(2) > xtitle("") ytitle("`Label`O''", size(vsmall)) > graphregion(color(white)) > xlabel(-6(1)0, labsize(small)) > ylabel(/*-400(150)200*/, labsize(small) ) > legend(off) > graphregion(margin(r+5)) > title("Post x Exp. State - `Title`T'':" "`Title`O''", pos(11) size(3.5)) > name(r`O'`T', replace) > ; 64. # delimit cr delimiter now cr . graph export "$plotdir/ESr_`O'`T'.png", replace width(4000) 65. . # delimit ; delimiter now ; . twoway > (rarea upperi_`O'`T' loweri_`O'`T' timeG if inrange(timeG, -20,20), color(gs12%35)) > (connected bi_`O'`T' timeG if inrange(timeG, -20,-2), > mcolor(cranberry) lwidth(medium) lcolor(cranberry) msize(small)) > (connected bi_`O'`T' timeG if inrange(timeG, 0,20), > mcolor(cranberry) lwidth(medium) lcolor(cranberry) msize(small)) > (function y = 0, range(-20 20) lcolor(gs10)), > xline(-.5 , lwidth(2.2) lcolor(gs10) ) > xsize(4) ysize(2) > xtitle("") ytitle("`Label`O''", size(vsmall)) > graphregion(color(white)) > xlabel(-20(5)20, labsize(small)) > ylabel(/*-400(150)200*/, labsize(small) ) > legend(off) > graphregion(margin(r+5)) > title("Total Effect Medicaid Exp. State - `Title`T'':" "`Title`O''", pos(11) size(3.5)) > name(i`O'`T', replace) > ; 66. # delimit cr delimiter now cr . graph export "$plotdir/ESi_`O'`T'.png", replace width(4000) 67. . //rename __hdfe2__ datefe`T' . } 68. } (1,424,947 missing values generated) (1,424,947 missing values generated) (1,424,947 missing values generated) (1,424,947 missing values generated) (1,424,947 missing values generated) (1,424,947 missing values generated) (1,424,947 missing values generated) (1,424,947 missing values generated) (1,424,947 missing values generated) note: 1bn.medicaidexp is probably collinear with the fixed effects (all partialled-out values are close to > zero; tol = 1.0e-09) (MWFE estimator converged in 1 iterations) note: 1.medicaidexp omitted because of collinearity HDFE Linear regression Number of obs = 1,281,980 Absorbing 1 HDFE group F( 27, 50) = 231.83 Statistics robust to heteroskedasticity Prob > F = 0.0000 R-squared = 0.0902 Adj R-squared = 0.0901 Within R-sq. = 0.0756 Number of clusters (stateid) = 51 Root MSE = 0.3276 (Std. Err. adjusted for 51 clusters in stateid) ----------------------------------------------------------------------------------------------------- | Robust medicaid | Coef. Std. Err. t P>|t| [95% Conf. Interval] ------------------------------------+---------------------------------------------------------------- 1.medicaidexp | 0 (omitted) 1.ys_Covid_1 | .0147778 .0039141 3.78 0.000 .0069161 .0226395 1.ys_Covid_2 | .0116291 .0026514 4.39 0.000 .0063036 .0169545 1.ys_Covid_3 | .0156508 .0036444 4.29 0.000 .0083308 .0229709 1.ys_Covid_4 | .013434 .0020207 6.65 0.000 .0093752 .0174928 1.ys_Covid_5 | .0042959 .0010267 4.18 0.000 .0022337 .0063582 1.ys_Covid_7 | .0455878 .0029167 15.63 0.000 .0397295 .0514462 | medicaidexp#ys_Covid_1 | 1 1 | -.0145737 .0057539 -2.53 0.014 -.0261307 -.0030167 | medicaidexp#ys_Covid_2 | 1 1 | -.003446 .0056096 -0.61 0.542 -.0147132 .0078212 | medicaidexp#ys_Covid_3 | 1 1 | -.0040844 .005401 -0.76 0.453 -.0149326 .0067639 | medicaidexp#ys_Covid_4 | 1 1 | .0006195 .0040333 0.15 0.879 -.0074817 .0087207 | medicaidexp#ys_Covid_5 | 1 1 | .0017619 .0013924 1.27 0.212 -.0010349 .0045586 | medicaidexp#ys_Covid_7 | 1 1 | .0074367 .0071483 1.04 0.303 -.0069211 .0217946 | female | .0381845 .0018181 21.00 0.000 .0345328 .0418362 | educ | Some HS | -.0025142 .0105309 -0.24 0.812 -.0236661 .0186376 HS grad | -.1011294 .0127576 -7.93 0.000 -.1267537 -.075505 Some college or Associate's degree | -.1516205 .0153928 -9.85 0.000 -.1825379 -.1207032 Bachelor's or graduate degree | -.2144609 .0202735 -10.58 0.000 -.2551815 -.1737402 | race | Hispanic | .040828 .010631 3.84 0.000 .019475 .0621809 Black Non-Hispanice | .0825418 .0047003 17.56 0.000 .073101 .0919825 Asian Non-Hispanice | .0318666 .011371 2.80 0.007 .0090273 .0547059 Other Non-Hispanice | .0569669 .0054851 10.39 0.000 .0459498 .067984 | marstat | Widowed | .0301489 .002936 10.27 0.000 .0242517 .036046 Divorced | .0635882 .0049375 12.88 0.000 .053671 .0735055 Separated | .0986986 .0069466 14.21 0.000 .084746 .1126513 Never married | .0571134 .0050187 11.38 0.000 .047033 .0671939 | age | .0023764 .0006318 3.76 0.000 .0011075 .0036453 | c.age#c.age | -.0000386 7.11e-06 -5.43 0.000 -.0000529 -.0000243 | _cons | .1848443 .0191041 9.68 0.000 .1464726 .2232161 ----------------------------------------------------------------------------------------------------- Absorbed degrees of freedom: -----------------------------------------------------+ Absorbed FE | Categories - Redundant = Num. Coefs | -------------+---------------------------------------| stateid | 51 51 0 *| -----------------------------------------------------+ * = FE nested within cluster; treated as redundant for DoF computation invalid syntax r(198); end of do-file r(198);
Sincerely,
Sumedha.
0 Response to Invalid syntax; not obvious what is wrong.
Post a Comment