-------------------------------------------------------------------------------------------- name: log: c:\Users\ccameron\Dropbox\Desktop\TEACHING\190\Causal Methods Slides\dind.txt log type: text opened on: 28 Nov 2023, 17:58:45 . . ********** OVERVIEW OF dind.do ********** . . * This STATA program is an example of differences in differences . * It is simple - there are only two time periods . . * Program by A. Colin Cameron Dept. of Economics Univ. of California - Davis . * Used for ECN 190 Research with Economics Data . . * To run you need files . * AED_HEALTHACCESS.DTA . * in your directory . . * The dataset is used in chapter 13.6 of . * A. Colin Cameron Analysis of Economics Data: An Introduction to Econometics . * https://cameron.econ.ucdavis.edu/ . . * Original source is Shinsuke Tanaka (2014), . * "Does Abolishing User Fees Lead to Improved Health Status? . * Evidence from Post-Apartheid South Africa", . * American Economics Journal: Economic Policy, 6(3), pages 282-312 . * Data at http://doi.org/10.3886/E114870V1 . . ********** SETUP ********** . . clear all . * set scheme s1mono /* Graphics scheme */ . . ************ DIFFERENCES IN DIFFERENCES . . use AED_HEALTHACCESS.DTA, clear (Data for A. Colin Cameron (2022), ANALYSIS OF ECONOMIC DATA, Amazon) . describe Contains data from AED_HEALTHACCESS.DTA Observations: 1,071 Data for A. Colin Cameron (2022), ANALYSIS OF ECONOMIC DATA, Amazon Variables: 26 22 Jan 2022 15:04 (_dta has notes) -------------------------------------------------------------------------------------------- Variable Storage Display Value name type format label Variable label -------------------------------------------------------------------------------------------- hhid93 double %10.0g Household identification No pcode double %8.0g 93: Person Code idcommunity double %10.0g Identifier for community year float %9.0g = 93 or 98 hightreat float %9.0g = 1 if community has clinic in 1993 post float %9.0g = 1 if year==98 and =0 if year==93 postXhigh float %9.0g = post times hightreat waz double %6.2f Weight for age z Score whz double %6.2f Weight for height z Score haz double %6.2f Height for age z Score fedu float %9.0g Father's education medu float %9.0g Mother's education hhsizep float %10.0g Household size (all members) lntotminc float %9.0g Log of monthly household income immuniz int %8.0g yes_no Number of immunization campaigns since 1993 nonclinic float %9.0g Number of health facilities other than clinic in 1993 male float %9.0g = 1 if male age double %10.0g Precise age in fractions of year age93_0 float %9.0g =1 if age 0 in 1993 age93_1 float %9.0g =1 if age 1 in 1993 age93_2 float %9.0g =1 if age 2 in 1993 age93_3 float %9.0g =1 if age 3 in 1993 age98_0 float %9.0g =1 if age 0 in 1998 age98_1 float %9.0g =1 if age 1 in 1998 age98_2 float %9.0g =1 if age 2 in 1998 age98_3 float %9.0g =1 if age 3 in 1998 -------------------------------------------------------------------------------------------- Sorted by: . summarize Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- hhid93 | 1,071 2066044 491434 590010 2440170 pcode | 1,071 24.50887 16.28817 2 57 idcommunity | 1,071 206.5882 49.14247 59 244 year | 1,071 95.33427 2.495666 93 98 hightreat | 1,071 .4276377 .4949671 0 1 -------------+--------------------------------------------------------- post | 1,071 .4668534 .4991332 0 1 postXhigh | 1,071 .1979458 .3986373 0 1 waz | 1,071 -.205873 1.587432 -5.88 4.94 whz | 1,071 .6390009 2.199942 -9.89 9.99 haz | 1,071 -.9497853 2.367617 -9.98 9.99 -------------+--------------------------------------------------------- fedu | 1,071 1.75817 3.096933 0 12 medu | 1,071 4.728291 3.638313 0 14 hhsizep | 1,071 11.1662 5.128117 2 34 lntotminc | 1,071 6.829278 1.017545 3.549378 9.846148 immuniz | 1,071 .4911298 .546583 0 2 -------------+--------------------------------------------------------- nonclinic | 1,071 .1204482 .4274049 0 3 male | 1,071 .5144725 .500024 0 1 age | 1,071 2.145798 1.057268 0 3.991781 age93_0 | 1,071 .10831 .3109167 0 1 age93_1 | 1,071 .1381886 .3452591 0 1 -------------+--------------------------------------------------------- age93_2 | 1,071 .140056 .3472073 0 1 age93_3 | 1,071 .146592 .3538639 0 1 age98_0 | 1,071 .0616246 .2405849 0 1 age98_1 | 1,071 .130719 .3372502 0 1 age98_2 | 1,071 .1447246 .3519873 0 1 -------------+--------------------------------------------------------- age98_3 | 1,071 .1297852 .336224 0 1 . . * All variables used below . describe idcommunity year hightreat post postXhigh waz whz /// > fedu medu hhsizep lntotminc immuniz nonclinic age Variable Storage Display Value name type format label Variable label -------------------------------------------------------------------------------------------- idcommunity double %10.0g Identifier for community year float %9.0g = 93 or 98 hightreat float %9.0g = 1 if community has clinic in 1993 post float %9.0g = 1 if year==98 and =0 if year==93 postXhigh float %9.0g = post times hightreat waz double %6.2f Weight for age z Score whz double %6.2f Weight for height z Score fedu float %9.0g Father's education medu float %9.0g Mother's education hhsizep float %10.0g Household size (all members) lntotminc float %9.0g Log of monthly household income immuniz int %8.0g yes_no Number of immunization campaigns since 1993 nonclinic float %9.0g Number of health facilities other than clinic in 1993 age double %10.0g Precise age in fractions of year . summarize idcommunity year hightreat post postXhigh waz whz /// > fedu medu hhsizep lntotminc immuniz nonclinic age Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- idcommunity | 1,071 206.5882 49.14247 59 244 year | 1,071 95.33427 2.495666 93 98 hightreat | 1,071 .4276377 .4949671 0 1 post | 1,071 .4668534 .4991332 0 1 postXhigh | 1,071 .1979458 .3986373 0 1 -------------+--------------------------------------------------------- waz | 1,071 -.205873 1.587432 -5.88 4.94 whz | 1,071 .6390009 2.199942 -9.89 9.99 fedu | 1,071 1.75817 3.096933 0 12 medu | 1,071 4.728291 3.638313 0 14 hhsizep | 1,071 11.1662 5.128117 2 34 -------------+--------------------------------------------------------- lntotminc | 1,071 6.829278 1.017545 3.549378 9.846148 immuniz | 1,071 .4911298 .546583 0 2 nonclinic | 1,071 .1204482 .4274049 0 3 age | 1,071 2.145798 1.057268 0 3.991781 . . * Key variables . describe waz hightreat post postXhigh waz whz Variable Storage Display Value name type format label Variable label -------------------------------------------------------------------------------------------- waz double %6.2f Weight for age z Score hightreat float %9.0g = 1 if community has clinic in 1993 post float %9.0g = 1 if year==98 and =0 if year==93 postXhigh float %9.0g = post times hightreat waz double %6.2f Weight for age z Score whz double %6.2f Weight for height z Score . summarize waz hightreat post postXhigh waz whz Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- waz | 1,071 -.205873 1.587432 -5.88 4.94 hightreat | 1,071 .4276377 .4949671 0 1 post | 1,071 .4668534 .4991332 0 1 postXhigh | 1,071 .1979458 .3986373 0 1 waz | 1,071 -.205873 1.587432 -5.88 4.94 -------------+--------------------------------------------------------- whz | 1,071 .6390009 2.199942 -9.89 9.99 . . * Difference in differences of mean calculation . sum waz if high==1 & post==0 Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- waz | 246 -.5452439 1.718157 -5.88 4.94 . scalar highpre = r(mean) . sum waz if high==1 & post==1 Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- waz | 212 .3214623 1.554139 -3.43 4.76 . scalar highpost = r(mean) . sum waz if high==0 & post==0 Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- waz | 325 -.4141846 1.607325 -4.57 4.7 . scalar lowpre = r(mean) . sum waz if high==0 & post==1 Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- waz | 288 -.0690972 1.345548 -3.83 4.83 . scalar lowpost = r(mean) . scalar highdiff = highpost - highpre . scalar lowdiff = lowpost - lowpre . scalar diffindiff = highdiff - lowdiff . display "highpre = " highpre highpre = -.5452439 . display "highpost = " highpost highpost = .32146226 . display "highdiff = " highdiff highdiff = .86670616 . display "lowpre = " lowpre lowpre = -.41418462 . display "lowpost = " lowpost lowpost = -.06909722 . display "highdiff = " highdiff highdiff = .86670616 . display "lowdiff = " lowdiff lowdiff = .3450874 . display "diffindiff = " diffindiff diffindiff = .52161877 . . * Diff-in-diff - no controls and cluster-robust standard errors . reg waz postXhigh post hightreat, vce(cluster idcommunity) noheader (Std. err. adjusted for 54 clusters in idcommunity) ------------------------------------------------------------------------------ | Robust waz | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- postXhigh | .5216188 .2352991 2.22 0.031 .0496685 .993569 post | .3450874 .1371018 2.52 0.015 .070096 .6200788 hightreat | -.1310593 .1968084 -0.67 0.508 -.525807 .2636884 _cons | -.4141846 .1151423 -3.60 0.001 -.6451308 -.1832384 ------------------------------------------------------------------------------ . . * Same with heteroskedastic-robust standard errors . reg waz postXhigh post hightreat, vce(robust) noheader ------------------------------------------------------------------------------ | Robust waz | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- postXhigh | .5216188 .1939607 2.69 0.007 .141031 .9022065 post | .3450874 .1193422 2.89 0.004 .1109153 .5792595 hightreat | -.1310593 .1412471 -0.93 0.354 -.4082128 .1460942 _cons | -.4141846 .0891878 -4.64 0.000 -.5891879 -.2391813 ------------------------------------------------------------------------------ . . * D in D with fixed effects for community and individual controls . xtset idcommunity Panel variable: idcommunity (unbalanced) . xtreg waz postXhigh fedu medu hhsizep lntotminc immuniz nonclinic /// > age93_0-age93_3 age98_0-age98_3, fe vce(robust) note: age98_3 omitted because of collinearity. Fixed-effects (within) regression Number of obs = 1,071 Group variable: idcommunity Number of groups = 54 R-squared: Obs per group: Within = 0.1154 min = 1 Between = 0.1154 avg = 19.8 Overall = 0.1147 max = 40 F(14, 53) = 14.46 corr(u_i, Xb) = -0.0541 Prob > F = 0.0000 (Std. err. adjusted for 54 clusters in idcommunity) ------------------------------------------------------------------------------ | Robust waz | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- postXhigh | .6380436 .2680681 2.38 0.021 .100367 1.17572 fedu | .0163998 .0186456 0.88 0.383 -.0209986 .0537982 medu | -.0139516 .016308 -0.86 0.396 -.0466614 .0187581 hhsizep | -.0143325 .0096093 -1.49 0.142 -.0336062 .0049413 lntotminc | .154542 .0549553 2.81 0.007 .0443156 .2647684 immuniz | .9246483 .3022693 3.06 0.003 .3183728 1.530924 nonclinic | -.3296642 .1824177 -1.81 0.076 -.6955477 .0362193 age93_0 | 1.595161 .3637885 4.38 0.000 .8654942 2.324829 age93_1 | .5998271 .3760631 1.60 0.117 -.15446 1.354114 age93_2 | .6738998 .4000106 1.68 0.098 -.1284199 1.47622 age93_3 | .3692614 .3873885 0.95 0.345 -.4077415 1.146264 age98_0 | .6115251 .2283999 2.68 0.010 .153413 1.069637 age98_1 | .3109072 .1628961 1.91 0.062 -.015821 .6376353 age98_2 | -.1958483 .1489495 -1.31 0.194 -.4946032 .1029066 age98_3 | 0 (omitted) _cons | -2.058981 .487321 -4.23 0.000 -3.036423 -1.081539 -------------+---------------------------------------------------------------- sigma_u | .73817753 sigma_e | 1.4566265 rho | .20433977 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . . * D in D with fixed effects for community and individual controls . reg waz postXhigh post hightreat i.idcommunity /// > fedu medu hhsizep lntotminc immuniz nonclinic, /// > vce(cluster idcommunity) noheader note: 242.idcommunity omitted because of collinearity. (Std. err. adjusted for 54 clusters in idcommunity) ------------------------------------------------------------------------------ | Robust waz | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- postXhigh | .6428807 .2710993 2.37 0.021 .0991243 1.186637 post | -.6807024 .3487963 -1.95 0.056 -1.380299 .0188944 hightreat | -.2911247 .2360665 -1.23 0.223 -.7646142 .1823648 | idcommunity | 70 | .2874699 .1059799 2.71 0.009 .074901 .5000387 71 | .3978011 .24053 1.65 0.104 -.0846411 .8802432 74 | -3.173181 .116653 -27.20 0.000 -3.407157 -2.939204 77 | 2.597571 .3122377 8.32 0.000 1.971302 3.223841 78 | .2160735 .1957466 1.10 0.275 -.1765445 .6086915 79 | -.2080409 .163213 -1.27 0.208 -.5354048 .119323 80 | .0015226 .1824792 0.01 0.993 -.3644842 .3675295 193 | -.7950822 .1792359 -4.44 0.000 -1.154584 -.4355806 195 | .0453894 .1675401 0.27 0.788 -.2906536 .3814324 196 | -.9717183 .0706266 -13.76 0.000 -1.113377 -.8300592 197 | -.8237864 .0896107 -9.19 0.000 -1.003523 -.64405 198 | .8921643 .1704257 5.23 0.000 .5503335 1.233995 200 | -.6562065 .098274 -6.68 0.000 -.8533192 -.4590939 201 | -.3800693 .1669547 -2.28 0.027 -.714938 -.0452006 202 | .9205801 .0688437 13.37 0.000 .7824971 1.058663 203 | -.3039892 .1881209 -1.62 0.112 -.681312 .0733336 204 | 1.090565 .1989837 5.48 0.000 .6914545 1.489676 205 | -.3395986 .0450451 -7.54 0.000 -.4299477 -.2492496 207 | -.5735619 .0972512 -5.90 0.000 -.7686232 -.3785007 208 | -.5948834 .0680983 -8.74 0.000 -.7314713 -.4582955 209 | -.7984668 .1692709 -4.72 0.000 -1.137981 -.4589524 211 | -.34306 .052726 -6.51 0.000 -.4488149 -.237305 212 | .5319096 .1698343 3.13 0.003 .191265 .8725541 213 | .6043919 .1773504 3.41 0.001 .2486721 .9601117 214 | -1.132115 .1796709 -6.30 0.000 -1.492489 -.7717403 215 | -.9287727 .1992899 -4.66 0.000 -1.328498 -.5290478 216 | -.3785829 .0481564 -7.86 0.000 -.4751725 -.2819933 219 | -.4933115 .042851 -11.51 0.000 -.5792597 -.4073633 220 | -.8763232 .0644265 -13.60 0.000 -1.005546 -.7471 221 | .3858579 .0626663 6.16 0.000 .2601652 .5115505 222 | -.0569208 .0597721 -0.95 0.345 -.1768085 .0629669 223 | .3442531 .0522848 6.58 0.000 .239383 .4491232 224 | .2853282 .0671984 4.25 0.000 .1505453 .4201112 225 | .9483909 .1937935 4.89 0.000 .5596903 1.337091 226 | .3390337 .0257013 13.19 0.000 .2874834 .390584 227 | -.2704414 .0310442 -8.71 0.000 -.3327083 -.2081746 228 | .3580386 .0666659 5.37 0.000 .2243237 .4917535 229 | -.1044712 .0258367 -4.04 0.000 -.156293 -.0526494 230 | .5981681 .0507661 11.78 0.000 .4963442 .6999921 231 | .1134669 .177068 0.64 0.524 -.2416865 .4686204 232 | -.4382279 .0495389 -8.85 0.000 -.5375904 -.3388654 233 | -.0842228 .1881413 -0.45 0.656 -.4615865 .2931409 234 | .0044622 .0955814 0.05 0.963 -.1872497 .1961742 235 | -.6604078 .1664768 -3.97 0.000 -.9943179 -.3264977 236 | .0432934 .0454 0.95 0.345 -.0477675 .1343543 237 | -.2455141 .2527029 -0.97 0.336 -.7523719 .2613437 238 | .553478 .1704869 3.25 0.002 .2115246 .8954314 239 | -.0976976 .0579561 -1.69 0.098 -.2139427 .0185476 240 | .2763189 .0323151 8.55 0.000 .211503 .3411347 241 | -.1351925 .2011154 -0.67 0.504 -.5385788 .2681938 242 | 0 (omitted) 243 | 1.165619 .268029 4.35 0.000 .6280209 1.703217 244 | -.3208512 .2078204 -1.54 0.129 -.7376861 .0959838 | fedu | .0106712 .0202978 0.53 0.601 -.030041 .0513834 medu | -.0048958 .0161178 -0.30 0.763 -.0372239 .0274324 hhsizep | -.0104237 .0104451 -1.00 0.323 -.0313741 .0105266 lntotminc | .1489382 .0571007 2.61 0.012 .0344087 .2634676 immuniz | .9473233 .2799104 3.38 0.001 .3858942 1.508753 nonclinic | -.334467 .1738546 -1.92 0.060 -.6831752 .0142412 _cons | -1.155682 .3758822 -3.07 0.003 -1.909606 -.4017578 ------------------------------------------------------------------------------ . . * Same results now if drop post and hightreat . reg waz postXhigh i.idcommunity /// > fedu medu hhsizep lntotminc immuniz nonclinic, /// > vce(cluster idcommunity) noheader (Std. err. adjusted for 54 clusters in idcommunity) ------------------------------------------------------------------------------ | Robust waz | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- postXhigh | .601971 .268016 2.25 0.029 .064399 1.139543 | idcommunity | 70 | .1933649 .1737214 1.11 0.271 -.1550761 .5418058 71 | .2259103 .2763652 0.82 0.417 -.3284081 .7802287 74 | -3.247119 .1573106 -20.64 0.000 -3.562644 -2.931594 77 | 2.264478 .247624 9.14 0.000 1.767807 2.761149 78 | -.1563362 .1573615 -0.99 0.325 -.4719633 .159291 79 | .0089766 .1663643 0.05 0.957 -.324708 .3426612 80 | -.3651805 .122693 -2.98 0.004 -.6112714 -.1190896 193 | -1.147544 .1105372 -10.38 0.000 -1.369253 -.9258341 195 | -.3069368 .1019059 -3.01 0.004 -.5113341 -.1025394 196 | -1.048101 .1710558 -6.13 0.000 -1.391196 -.7050066 197 | -.9015562 .1645134 -5.48 0.000 -1.231528 -.5715842 198 | .5366655 .0902965 5.94 0.000 .3555537 .7177773 200 | -.7424962 .1357071 -5.47 0.000 -1.01469 -.4703021 201 | -.7420249 .1024836 -7.24 0.000 -.947581 -.5364689 202 | .8699238 .0732786 11.87 0.000 .7229454 1.016902 203 | -.6664475 .1079494 -6.17 0.000 -.8829666 -.4499285 204 | .7423737 .1585027 4.68 0.000 .4244576 1.06029 205 | -.4176355 .1697906 -2.46 0.017 -.7581922 -.0770788 207 | -.6385605 .1506371 -4.24 0.000 -.9407002 -.3364208 208 | -.6710044 .1744953 -3.85 0.000 -1.020998 -.3210111 209 | -1.158096 .109167 -10.61 0.000 -1.377057 -.9391348 211 | -.4320618 .1428781 -3.02 0.004 -.7186389 -.1454846 212 | .175716 .1164421 1.51 0.137 -.0578371 .4092692 213 | .2483837 .1085215 2.29 0.026 .030717 .4660503 214 | -1.485294 .0928221 -16.00 0.000 -1.671472 -1.299117 215 | -1.28204 .1331408 -9.63 0.000 -1.549086 -1.014993 216 | -.4708782 .1550481 -3.04 0.004 -.7818653 -.159891 219 | -.5885988 .1439383 -4.09 0.000 -.8773025 -.299895 220 | -.9704521 .1665053 -5.83 0.000 -1.304419 -.6364849 221 | .2886973 .1467395 1.97 0.054 -.0056249 .5830195 222 | -.1326631 .1466616 -0.90 0.370 -.4268289 .1615028 223 | .2565938 .158896 1.61 0.112 -.0621112 .5752989 224 | .1959028 .1369018 1.43 0.158 -.0786874 .470493 225 | .5698398 .1641492 3.47 0.001 .2405982 .8990815 226 | .2609457 .1454794 1.79 0.079 -.0308491 .5527405 227 | -.3583745 .167505 -2.14 0.037 -.6943471 -.022402 228 | .2722016 .1654947 1.64 0.106 -.0597388 .6041421 229 | -.19443 .162228 -1.20 0.236 -.5198182 .1309581 230 | .5167931 .1595965 3.24 0.002 .1966831 .8369032 231 | -.241676 .1175527 -2.06 0.045 -.4774569 -.0058951 232 | -.525243 .1442365 -3.64 0.001 -.8145448 -.2359411 233 | -.468229 .1626382 -2.88 0.006 -.7944399 -.1420182 234 | -.1040654 .2243891 -0.46 0.645 -.5541331 .3460022 235 | -1.023279 .0880237 -11.63 0.000 -1.199832 -.8467254 236 | -.0436078 .1449025 -0.30 0.765 -.3342454 .2470299 237 | -.6546086 .2663169 -2.46 0.017 -1.188773 -.1204446 238 | .1986145 .1065013 1.86 0.068 -.015 .4122291 239 | -.1836079 .155098 -1.18 0.242 -.494695 .1274792 240 | .2001161 .1575129 1.27 0.209 -.1158147 .516047 241 | -.5025294 .1541117 -3.26 0.002 -.8116382 -.1934206 242 | -.0814356 .1562613 -0.52 0.604 -.3948561 .2319848 243 | .7516685 .2785481 2.70 0.009 .1929717 1.310365 244 | -.6799089 .1711285 -3.97 0.000 -1.023149 -.3366686 | fedu | .0106763 .0202474 0.53 0.600 -.0299348 .0512874 medu | -.004997 .0160621 -0.31 0.757 -.0372135 .0272195 hhsizep | -.0105404 .0105671 -1.00 0.323 -.0317353 .0106545 lntotminc | .1436456 .0584701 2.46 0.017 .0263695 .2609217 immuniz | .3358176 .1382452 2.43 0.019 .0585328 .6131023 nonclinic | -.2894748 .2114265 -1.37 0.177 -.7135427 .1345932 _cons | -1.064573 .4408236 -2.41 0.019 -1.948753 -.1803924 ------------------------------------------------------------------------------ . . ********** Multiple periods of data . . * Example from Stata documentation and from help didregress . * y is satis (Patient satisfaction score) . * Treatment is procedure = 1 . * Group is hospital (there are 46) . * Time is month (there are 7 months: January to July) . * Treatment begins in April at 18 of the 46 hospitals . . clear . webuse hospdd (Artificial hospital admission procedure data) . describe Contains data from https://www.stata-press.com/data/r18/hospdd.dta Observations: 7,368 Artificial hospital admission procedure data Variables: 5 7 Mar 2023 19:52 -------------------------------------------------------------------------------------------- Variable Storage Display Value name type format label Variable label -------------------------------------------------------------------------------------------- hospital byte %9.0g Hospital ID frequency byte %9.0g size Hospital visit frequency month byte %8.0g mnth Month procedure byte %9.0g pol Admission procedure satis float %9.0g Patient satisfaction score -------------------------------------------------------------------------------------------- Sorted by: hospital . summarize Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- hospital | 7,368 22.83822 13.57186 1 46 frequency | 7,368 2.473398 1.163957 1 4 month | 7,368 3.625 2.117778 1 7 procedure | 7,368 .2079262 .4058512 0 1 satis | 7,368 3.619074 1.05576 .5467862 9.712885 . didregress (satis)(procedure), group(hospital) time(month) Treatment and time information Time variable: month Control: procedure = 0 Treatment: procedure = 1 ----------------------------------- | Control Treatment -------------+--------------------- Group | hospital | 28 18 -------------+--------------------- Time | Minimum | 1 4 Maximum | 1 4 ----------------------------------- Difference-in-differences regression Number of obs = 7,368 Data type: Repeated cross-sectional (Std. err. adjusted for 46 clusters in hospital) ------------------------------------------------------------------------------- | Robust satis | Coefficient std. err. t P>|t| [95% conf. interval] --------------+---------------------------------------------------------------- ATET | procedure | (New vs Old) | .8479879 .0321121 26.41 0.000 .7833108 .912665 ------------------------------------------------------------------------------- Note: ATET estimate adjusted for group effects and time effects. . . * The following gives the same results as didregress . regress satis procedure i.hospital i.month, vce(cluster hospital) Linear regression Number of obs = 7,368 F(6, 45) = . Prob > F = . R-squared = 0.5333 Root MSE = .72384 (Std. err. adjusted for 46 clusters in hospital) ------------------------------------------------------------------------------ | Robust satis | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- procedure | .8479879 .0321121 26.41 0.000 .7833108 .912665 | hospital | 2 | .4085664 2.03e-14 2.0e+13 0.000 .4085664 .4085664 3 | .5336248 2.03e-14 2.6e+13 0.000 .5336248 .5336248 4 | .2275102 2.04e-14 1.1e+13 0.000 .2275102 .2275102 5 | -.1453529 2.04e-14 -7.1e+12 0.000 -.1453529 -.1453529 6 | .4478634 2.04e-14 2.2e+13 0.000 .4478634 .4478634 7 | 1.404416 2.07e-14 6.8e+13 0.000 1.404416 1.404416 8 | .0718758 2.03e-14 3.5e+12 0.000 .0718758 .0718758 9 | -1.518515 2.03e-14 -7.5e+13 0.000 -1.518515 -1.518515 10 | 1.682845 2.03e-14 8.3e+13 0.000 1.682845 1.682845 11 | .2209653 2.03e-14 1.1e+13 0.000 .2209653 .2209653 12 | -.0953034 2.03e-14 -4.7e+12 0.000 -.0953034 -.0953034 13 | .4955931 2.03e-14 2.4e+13 0.000 .4955931 .4955931 14 | .2330426 2.03e-14 1.1e+13 0.000 .2330426 .2330426 15 | -.1444935 2.03e-14 -7.1e+12 0.000 -.1444935 -.1444935 16 | 1.414268 2.04e-14 6.9e+13 0.000 1.414268 1.414268 17 | .4235429 2.03e-14 2.1e+13 0.000 .4235429 .4235429 18 | .1532761 2.03e-14 7.6e+12 0.000 .1532761 .1532761 19 | -.7453017 .0160561 -46.42 0.000 -.7776403 -.7129632 20 | .0473874 .0160561 2.95 0.005 .0150489 .079726 21 | 1.194337 .0160561 74.39 0.000 1.161998 1.226676 22 | .7993153 .0160561 49.78 0.000 .7669768 .8316539 23 | .7017202 .0160561 43.70 0.000 .6693817 .7340588 24 | -.308126 .0160561 -19.19 0.000 -.3404646 -.2757875 25 | .6464736 .0160561 40.26 0.000 .6141351 .6788122 26 | .2142471 .0160561 13.34 0.000 .1819086 .2465857 27 | -.3986544 .0160561 -24.83 0.000 -.430993 -.3663159 28 | .7119953 .0160561 44.34 0.000 .6796568 .7443339 29 | .2485512 .0160561 15.48 0.000 .2162127 .2808898 30 | -.167922 .0160561 -10.46 0.000 -.2002606 -.1355835 31 | .5120848 .0160561 31.89 0.000 .4797462 .5444233 32 | -.3233456 .0160561 -20.14 0.000 -.3556842 -.2910071 33 | -.4539752 .0160561 -28.27 0.000 -.4863137 -.4216366 34 | -.0004123 .0160561 -0.03 0.980 -.0327509 .0319262 35 | .354111 .0160561 22.05 0.000 .3217724 .3864495 36 | 2.138142 .0160561 133.17 0.000 2.105804 2.170481 37 | .1404036 .0160561 8.74 0.000 .108065 .1727421 38 | -.086806 .0160561 -5.41 0.000 -.1191445 -.0544674 39 | -.0234969 .0160561 -1.46 0.150 -.0558355 .0088416 40 | 1.121533 .0160561 69.85 0.000 1.089195 1.153872 41 | -.1497346 .0160561 -9.33 0.000 -.1820731 -.117396 42 | .8811369 .0160561 54.88 0.000 .8487984 .9134755 43 | -.7724325 .0160561 -48.11 0.000 -.8047711 -.740094 44 | .034412 .0160561 2.14 0.038 .0020735 .0667506 45 | -.2137495 .0160561 -13.31 0.000 -.246088 -.1814109 46 | .0784915 .0160561 4.89 0.000 .0461529 .11083 | month | February | -.0096077 .0184317 -0.52 0.605 -.0467311 .0275158 March | .0219686 .018251 1.20 0.235 -.0147907 .0587279 April | -.0032839 .0221028 -0.15 0.883 -.0478013 .0412335 May | -.0094027 .0232399 -0.40 0.688 -.0562103 .0374048 June | -.0038375 .0190634 -0.20 0.841 -.0422332 .0345581 July | -.0111941 .0230029 -0.49 0.629 -.0575244 .0351361 | _cons | 3.171657 .0172328 184.05 0.000 3.136948 3.206365 ------------------------------------------------------------------------------ . * This gives heterosedastic robust standard errors . regress satis procedure i.hospital i.month, vce(robust) Linear regression Number of obs = 7,368 F(52, 7315) = 145.58 Prob > F = 0.0000 R-squared = 0.5333 Root MSE = .72384 ------------------------------------------------------------------------------ | Robust satis | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- procedure | .8479879 .0353158 24.01 0.000 .7787587 .917217 | hospital | 2 | .4085664 .0736459 5.55 0.000 .2641992 .5529337 3 | .5336248 .078196 6.82 0.000 .3803381 .6869116 4 | .2275102 .0701131 3.24 0.001 .0900683 .3649521 5 | -.1453529 .0669239 -2.17 0.030 -.2765431 -.0141628 6 | .4478634 .0772682 5.80 0.000 .2963955 .5993314 7 | 1.404416 .0907478 15.48 0.000 1.226524 1.582308 8 | .0718758 .070372 1.02 0.307 -.0660736 .2098251 9 | -1.518515 .0753181 -20.16 0.000 -1.66616 -1.37087 10 | 1.682845 .0981337 17.15 0.000 1.490474 1.875215 11 | .2209653 .0739352 2.99 0.003 .076031 .3658997 12 | -.0953034 .067656 -1.41 0.159 -.2279286 .0373218 13 | .4955931 .082528 6.01 0.000 .3338144 .6573717 14 | .2330426 .087292 2.67 0.008 .0619251 .4041602 15 | -.1444935 .0703524 -2.05 0.040 -.2824045 -.0065825 16 | 1.414268 .0954734 14.81 0.000 1.227113 1.601423 17 | .4235429 .0790501 5.36 0.000 .268582 .5785038 18 | .1532761 .0836979 1.83 0.067 -.0107961 .3173482 19 | -.7453017 .0676189 -11.02 0.000 -.8778543 -.6127492 20 | .0473874 .0706124 0.67 0.502 -.0910333 .1858081 21 | 1.194337 .0820983 14.55 0.000 1.033401 1.355273 22 | .7993153 .0923888 8.65 0.000 .6182067 .9804239 23 | .7017202 .0795209 8.82 0.000 .5458362 .8576042 24 | -.308126 .0785678 -3.92 0.000 -.4621416 -.1541105 25 | .6464736 .077954 8.29 0.000 .4936614 .7992859 26 | .2142471 .0769108 2.79 0.005 .0634798 .3650144 27 | -.3986544 .0648957 -6.14 0.000 -.5258687 -.2714401 28 | .7119953 .0894365 7.96 0.000 .5366741 .8873166 29 | .2485512 .0734677 3.38 0.001 .1045333 .3925691 30 | -.167922 .0775107 -2.17 0.030 -.3198654 -.0159786 31 | .5120848 .081409 6.29 0.000 .3524996 .67167 32 | -.3233456 .0686104 -4.71 0.000 -.4578419 -.1888494 33 | -.4539752 .0643167 -7.06 0.000 -.5800543 -.327896 34 | -.0004123 .0681337 -0.01 0.995 -.1339741 .1331494 35 | .354111 .0706123 5.01 0.000 .2156904 .4925315 36 | 2.138142 .0813612 26.28 0.000 1.978651 2.297634 37 | .1404036 .0920848 1.52 0.127 -.0401092 .3209164 38 | -.086806 .0669567 -1.30 0.195 -.2180605 .0444486 39 | -.0234969 .0726939 -0.32 0.747 -.1659978 .119004 40 | 1.121533 .0882126 12.71 0.000 .948611 1.294455 41 | -.1497346 .0684966 -2.19 0.029 -.2840077 -.0154614 42 | .8811369 .0928764 9.49 0.000 .6990724 1.063201 43 | -.7724325 .0677634 -11.40 0.000 -.9052684 -.6395967 44 | .034412 .074755 0.46 0.645 -.1121294 .1809535 45 | -.2137495 .0663136 -3.22 0.001 -.3437432 -.0837558 46 | .0784915 .0707812 1.11 0.267 -.0602602 .2172431 | month | February | -.0096077 .0282793 -0.34 0.734 -.0650433 .045828 March | .0219686 .0281552 0.78 0.435 -.0332237 .0771609 April | -.0032839 .031578 -0.10 0.917 -.0651859 .0586182 May | -.0094027 .0312269 -0.30 0.763 -.0706164 .0518109 June | -.0038375 .0318049 -0.12 0.904 -.0661843 .0585092 July | -.0111941 .031239 -0.36 0.720 -.0724317 .0500434 | _cons | 3.171657 .0537795 58.98 0.000 3.066233 3.27708 ------------------------------------------------------------------------------ . . * Check parallel trends . didregress (satis)(procedure), group(hospital) time(month) Treatment and time information Time variable: month Control: procedure = 0 Treatment: procedure = 1 ----------------------------------- | Control Treatment -------------+--------------------- Group | hospital | 28 18 -------------+--------------------- Time | Minimum | 1 4 Maximum | 1 4 ----------------------------------- Difference-in-differences regression Number of obs = 7,368 Data type: Repeated cross-sectional (Std. err. adjusted for 46 clusters in hospital) ------------------------------------------------------------------------------- | Robust satis | Coefficient std. err. t P>|t| [95% conf. interval] --------------+---------------------------------------------------------------- ATET | procedure | (New vs Old) | .8479879 .0321121 26.41 0.000 .7833108 .912665 ------------------------------------------------------------------------------- Note: ATET estimate adjusted for group effects and time effects. . estat trendplots // Do pretreatment trends seem similar? . estat ptrends // A test Parallel-trends test (pretreatment time period) H0: Linear trends are parallel F(1, 45) = 0.55 Prob > F = 0.4615 . . ********** CLOSE OUTPUT . log close name: log: c:\Users\ccameron\Dropbox\Desktop\TEACHING\190\Causal Methods Slides\dind.txt log type: text closed on: 28 Nov 2023, 17:58:49 --------------------------------------------------------------------------------------------