--------------------------------------------------------------------------------- name: log: c:\Users\ccameron\Dropbox\Desktop\TEACHING\190\Methods\treat.txt log type: text opened on: 21 Mar 2023, 14:04:35 . . ********** OVERVIEW OF treat.do ********** . . * This STATA program is an example of regression discontinuity design . . * Program by A. Colin Cameron Dept. of Economics Univ. of California - Davis . * Used for ECN 190 Research with Economics Data . . * To run you need file . * mus224ohiesmallrecode.dta . * in your directory . . * The dataset is used in chapter 24 of . * A. Colin Cameron and Pravin K. Trivedi (2022) . * Microeconometrics using Stata, second edition, volume 2. . . ********** SETUP ********** . . clear all . set scheme s1mono /* Graphics scheme */ . . *********** . . * Variables: (1) outcomes (2) z: treatment related (3) x: outcome related . use mus224ohiesmallrecode, clear (A.C.Cameron & P.K.Trivedi (2022): Microeconometrics Using Stata, 2e) . global outcomes oop dowe ervisits // Outcome variables . global y oop // Outcome variable for this chapter . global hh dhhsize2 dhhsize3 // Household size dummies . global wave dlotdraw* dsurvdraw* // Lottery and survey draws . global zlist $hh $wave // z variables for the treatment . global xlist dsmoke hhinc deduc2-deduc4 demploy2-demploy4 // x for outcome . . * Variable descriptions and summary statistics . describe oop lottery household_id $xlist Variable Storage Display Value name type format label Variable label --------------------------------------------------------------------------------- oop float %9.0g Out of pocket costs (cost_tot_oop_mod_12m) lottery byte %12.0g lottery Selected in the lottery household_id float %9.0g Scrambled household identifier dsmoke byte %10.0g smk_lbl Currently smoke cigs (smk_curr_12m) hhinc float %3.0f Household income as % of federal poverty line (hhinc_pctfpl_12m) deduc2 byte %8.0g HS diploma or GED (edu_12m_2) deduc3 byte %8.0g Voc or 2yr degree (edu_12m_3) deduc4 byte %8.0g Four year degree (edu_12m_4) demploy2 byte %8.0g Work < 20 hrs/wk (employ_hrs_12m_2) demploy3 byte %8.0g Work 20–29 hrs/wk (employ_hrs_12m_3) demploy4 byte %8.0g Work 30+ hrs/wk (employ_hrs_12m_4) . global xlist dsmoke hhinc deduc2-deduc4 demploy2-demploy4 . summarize oop lottery $xlist Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- oop | 22,679 269.0062 733.0821 0 9400 lottery | 22,679 .4972001 .5000032 0 1 dsmoke | 22,154 2.262661 .9171565 1 3 hhinc | 20,478 76.97273 69.16905 0 461.6898 deduc2 | 21,986 .4982716 .5000084 0 1 -------------+--------------------------------------------------------- deduc3 | 21,986 .2204585 .4145653 0 1 deduc4 | 21,986 .1137997 .317575 0 1 demploy2 | 22,411 .0912052 .2879071 0 1 demploy3 | 22,411 .0999509 .2999412 0 1 demploy4 | 22,411 .2638436 .4407254 0 1 . describe $zlist // Indiviudal controls Variable Storage Display Value name type format label Variable label --------------------------------------------------------------------------------- dhhsize2 byte %8.0g 2 in hh (dddnumhh_li_2) dhhsize3 byte %8.0g 3 in hh (dddnumhh_li_3) dlotdraw2 byte %8.0g draw_lottery==2 (llldraw_lot_2) dlotdraw3 byte %8.0g draw_lottery==3 (llldraw_lot_3) dlotdraw4 byte %8.0g draw_lottery==4 (llldraw_lot_4) dlotdraw5 byte %8.0g draw_lottery==5 (llldraw_lot_5) dlotdraw6 byte %8.0g draw_lottery==6 (llldraw_lot_6) dlotdraw7 byte %8.0g draw_lottery==7 (llldraw_lot_7) dlotdraw8 byte %8.0g draw_lottery==8 (llldraw_lot_8) dsurvdraw2 byte %8.0g draw_survey==2 (ddddraw_sur_2) dsurvdraw3 byte %8.0g draw_survey==3 (ddddraw_sur_3) dsurvdraw4 byte %8.0g draw_survey==4 (ddddraw_sur_4) dsurvdraw5 byte %8.0g draw_survey==5 (ddddraw_sur_5) dsurvdraw6 byte %8.0g draw_survey==6 (ddddraw_sur_6) dsurvdraw7 byte %8.0g draw_survey==7 (ddddraw_sur_7) . global zlist dhhsize2 dhhsize3 dlotdraw* dsurvdraw* . summarize $zlist // Household size and lottery and survey draws Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- dhhsize2 | 22,679 .2963094 .4566392 0 1 dhhsize3 | 22,679 .0025133 .0500713 0 1 dlotdraw2 | 22,679 .1050311 .3066002 0 1 dlotdraw3 | 22,679 .1028705 .3037964 0 1 dlotdraw4 | 22,679 .1014595 .3019429 0 1 -------------+--------------------------------------------------------- dlotdraw5 | 22,679 .0970501 .2960325 0 1 dlotdraw6 | 22,679 .1974955 .3981181 0 1 dlotdraw7 | 22,679 .1934389 .3950027 0 1 dlotdraw8 | 22,679 .0995194 .2993647 0 1 dsurvdraw2 | 22,679 .1124829 .3159666 0 1 -------------+--------------------------------------------------------- dsurvdraw3 | 22,679 .1127034 .3162368 0 1 dsurvdraw4 | 22,679 .1404383 .3474488 0 1 dsurvdraw5 | 22,679 .1414084 .34845 0 1 dsurvdraw6 | 22,679 .2043741 .4032524 0 1 dsurvdraw7 | 22,679 .173244 .3784664 0 1 . . * Lottery dummy varies with household size and lottery and survey waves . regress lottery $zlist, vce(cluster household_id) Linear regression Number of obs = 22,679 F(15, 20147) = 93.29 Prob > F = 0.0000 R-squared = 0.0677 Root MSE = .48294 (Std. err. adjusted for 20,148 clusters in household_id) ------------------------------------------------------------------------------ | Robust lottery | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- dhhsize2 | .0651882 .0088219 7.39 0.000 .0478965 .0824798 dhhsize3 | .2807319 .0618745 4.54 0.000 .1594529 .402011 dlotdraw2 | .002456 .0168842 0.15 0.884 -.0306384 .0355504 dlotdraw3 | .0006732 .016864 0.04 0.968 -.0323816 .0337279 dlotdraw4 | .0541089 .0164205 3.30 0.001 .0219234 .0862944 dlotdraw5 | .0747288 .016741 4.46 0.000 .0419149 .1075426 dlotdraw6 | .0850831 .0144081 5.91 0.000 .056842 .1133243 dlotdraw7 | .0959815 .0144576 6.64 0.000 .0676434 .1243197 dlotdraw8 | .0855691 .0165617 5.17 0.000 .0531068 .1180315 dsurvdraw2 | .0122423 .0188461 0.65 0.516 -.0246976 .0491822 dsurvdraw3 | .0205117 .0188443 1.09 0.276 -.0164247 .0574481 dsurvdraw4 | -.1936876 .0163184 -11.87 0.000 -.225673 -.1617021 dsurvdraw5 | -.2042628 .0162951 -12.54 0.000 -.2362026 -.1723231 dsurvdraw6 | -.2686614 .0149923 -17.92 0.000 -.2980475 -.2392753 dsurvdraw7 | -.3149375 .0148982 -21.14 0.000 -.3441391 -.2857359 _cons | .5820885 .011587 50.24 0.000 .559377 .6048001 ------------------------------------------------------------------------------ . . regress oop lottery, vce(cluster household_id) noheader (Std. err. adjusted for 20,148 clusters in household_id) ------------------------------------------------------------------------------ | Robust oop | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- lottery | -44.66267 9.921594 -4.50 0.000 -64.1098 -25.21553 _cons | 291.2125 7.120921 40.90 0.000 277.2549 305.1701 ------------------------------------------------------------------------------ . . * Control function approach . qui regress $y lottery, vce(cluster household_id) . estimates store Diff_clu . qui regress $y lottery $zlist, vce(cluster household_id) . estimates store zlist . qui regress $y lottery $xlist, vce(cluster household_id) . estimates store xlist . qui regress $y lottery $zlist $xlist, vce(cluster household_id) . estimates store Both . estimates table Diff_clu zlist xlist Both, keep(lottery) /// > b(%8.4f) se stat(N r2) ---------------------------------------------------------- Variable | Diff_clu zlist xlist Both -------------+-------------------------------------------- lottery | -44.6627 -40.9243 -45.7420 -40.1693 | 9.9216 10.1302 10.6484 10.8169 -------------+-------------------------------------------- N | 22679 22679 19393 19393 r2 | 0.0009 0.0018 0.0147 0.0154 ---------------------------------------------------------- Legend: b/se . . * Regression-adjusted ATE using $zlist and $xlist . teffects ra ($y $xlist $zlist ) (lottery), nolog vce(cluster household_id) Treatment-effects estimation Number of obs = 19,393 Estimator : regression adjustment Outcome model : linear Treatment model: none (Std. err. adjusted for 17,348 clusters in household_id) -------------------------------------------------------------------------------- | Robust oop | Coefficient std. err. z P>|z| [95% conf. interval] ---------------+---------------------------------------------------------------- ATE | lottery | (Selected | vs | Not selected) | -40.44588 10.94579 -3.70 0.000 -61.89924 -18.99252 ---------------+---------------------------------------------------------------- POmean | lottery | Not selected | 292.1394 7.693716 37.97 0.000 277.06 307.2188 -------------------------------------------------------------------------------- . . * Inverse probability weighting using $zlist . teffects ipw ($y) (lottery $zlist), nolog vce(cluster household_id) Treatment-effects estimation Number of obs = 22,679 Estimator : inverse-probability weights Outcome model : weighted mean Treatment model: logit (Std. err. adjusted for 20,148 clusters in household_id) -------------------------------------------------------------------------------- | Robust oop | Coefficient std. err. z P>|z| [95% conf. interval] ---------------+---------------------------------------------------------------- ATE | lottery | (Selected | vs | Not selected) | -39.56951 10.12338 -3.91 0.000 -59.41098 -19.72804 ---------------+---------------------------------------------------------------- POmean | lottery | Not selected | 286.0328 7.275387 39.32 0.000 271.7733 300.2923 -------------------------------------------------------------------------------- . . * Doubly-robust augmented IPW . teffects aipw ($y $xlist) (lottery $zlist), aequations nolog /// > vce(cluster household_id) Treatment-effects estimation Number of obs = 19,393 Estimator : augmented IPW Outcome model : linear by ML Treatment model: logit (Std. err. adjusted for 17,348 clusters in household_id) -------------------------------------------------------------------------------- | Robust oop | Coefficient std. err. z P>|z| [95% conf. interval] ---------------+---------------------------------------------------------------- ATE | lottery | (Selected | vs | Not selected) | -38.66964 10.79616 -3.58 0.000 -59.82973 -17.50956 ---------------+---------------------------------------------------------------- POmean | lottery | Not selected | 290.2338 7.720553 37.59 0.000 275.1018 305.3658 ---------------+---------------------------------------------------------------- OME0 | dsmoke | .9205123 8.662252 0.11 0.915 -16.05719 17.89821 hhinc | 1.005393 .1398412 7.19 0.000 .731309 1.279477 deduc2 | 8.705563 21.02138 0.41 0.679 -32.49559 49.90671 deduc3 | 78.9117 25.07941 3.15 0.002 29.75696 128.0664 deduc4 | 61.82869 29.22027 2.12 0.034 4.558018 119.0994 demploy2 | -16.27391 26.17013 -0.62 0.534 -67.56643 35.01861 demploy3 | -27.16429 24.70588 -1.10 0.272 -75.58692 21.25834 demploy4 | -27.29717 20.0837 -1.36 0.174 -66.66049 12.06615 _cons | 199.0383 25.9641 7.67 0.000 148.1496 249.927 ---------------+---------------------------------------------------------------- OME1 | dsmoke | 23.37641 8.211131 2.85 0.004 7.282887 39.46993 hhinc | 1.1747 .1409721 8.33 0.000 .8983998 1.451 deduc2 | -26.81169 22.21343 -1.21 0.227 -70.34921 16.72582 deduc3 | 38.89857 26.51898 1.47 0.142 -13.07768 90.87481 deduc4 | 17.02745 33.1716 0.51 0.608 -47.98769 82.04259 demploy2 | -59.06455 21.31782 -2.77 0.006 -100.8467 -17.2824 demploy3 | -74.72525 21.30281 -3.51 0.000 -116.478 -32.97251 demploy4 | -18.49857 20.74892 -0.89 0.373 -59.1657 22.16856 _cons | 127.8238 25.06627 5.10 0.000 78.69479 176.9528 ---------------+---------------------------------------------------------------- TME1 | dhhsize2 | .2712528 .0397604 6.82 0.000 .1933239 .3491817 dhhsize3 | 1.671956 .699984 2.39 0.017 .300013 3.0439 dlotdraw2 | .0329293 .0817694 0.40 0.687 -.1273357 .1931943 dlotdraw3 | -.0134305 .0800556 -0.17 0.867 -.1703366 .1434756 dlotdraw4 | .2419665 .077133 3.14 0.002 .0907886 .3931443 dlotdraw5 | .3180178 .0781217 4.07 0.000 .1649021 .4711335 dlotdraw6 | .3624306 .0681201 5.32 0.000 .2289176 .4959436 dlotdraw7 | .437767 .0687437 6.37 0.000 .3030318 .5725023 dlotdraw8 | .3686761 .0777056 4.74 0.000 .216376 .5209762 dsurvdraw2 | .0720634 .093083 0.77 0.439 -.110376 .2545028 dsurvdraw3 | .0894928 .0923688 0.97 0.333 -.0915468 .2705323 dsurvdraw4 | -.8057285 .0764003 -10.55 0.000 -.9554703 -.6559866 dsurvdraw5 | -.8464725 .0764515 -11.07 0.000 -.9963147 -.6966302 dsurvdraw6 | -1.117297 .0717738 -15.57 0.000 -1.257971 -.9766228 dsurvdraw7 | -1.319487 .0724789 -18.21 0.000 -1.461543 -1.177431 _cons | .3340067 .0534825 6.25 0.000 .2291829 .4388306 -------------------------------------------------------------------------------- . . * Propensity score matching using $zlist . teffects psmatch ($y) (lottery $zlist) Treatment-effects estimation Number of obs = 22,679 Estimator : propensity-score matching Matches: requested = 1 Outcome model : matching min = 1 Treatment model: logit max = 1018 -------------------------------------------------------------------------------- | AI robust oop | Coefficient std. err. z P>|z| [95% conf. interval] ---------------+---------------------------------------------------------------- ATE | lottery | (Selected | vs | Not selected) | -48.935 14.08062 -3.48 0.001 -76.53251 -21.33749 -------------------------------------------------------------------------------- . . * Covariate balance summary . teffects ipw ($y) (lottery $zlist), nolog vce(cluster household_id) Treatment-effects estimation Number of obs = 22,679 Estimator : inverse-probability weights Outcome model : weighted mean Treatment model: logit (Std. err. adjusted for 20,148 clusters in household_id) -------------------------------------------------------------------------------- | Robust oop | Coefficient std. err. z P>|z| [95% conf. interval] ---------------+---------------------------------------------------------------- ATE | lottery | (Selected | vs | Not selected) | -39.56951 10.12338 -3.91 0.000 -59.41098 -19.72804 ---------------+---------------------------------------------------------------- POmean | lottery | Not selected | 286.0328 7.275387 39.32 0.000 271.7733 300.2923 -------------------------------------------------------------------------------- . tebalance summarize Covariate balance summary Raw Weighted ----------------------------------------- Number of obs = 22,679 22,679.0 Treated obs = 11,276 11,151.4 Control obs = 11,403 11,527.6 ----------------------------------------- ----------------------------------------------------------------- |Standardized differences Variance ratio | Raw Weighted Raw Weighted ----------------+------------------------------------------------ dhhsize2 | .1939117 .0060577 1.19006 1.005543 dhhsize3 | .0797051 .0021402 8.56137 1.04358 dlotdraw2 | .0331758 .0015502 1.089294 1.004479 dlotdraw3 | .0365961 .0046157 1.100489 1.013669 dlotdraw4 | -.0257401 -.0069954 .9342648 .9817981 dlotdraw5 | .0003948 -.0069064 1.001076 .9816374 dlotdraw6 | -.0083996 -.0028377 .9873158 .9960122 dlotdraw7 | -.0192988 .0054252 .970481 1.007623 dlotdraw8 | -.0254451 .0079989 .9341439 1.020275 dsurvdraw2 | .2260162 -.0055742 1.772475 .9868448 dsurvdraw3 | .2397501 -.0094081 1.838261 .9780227 dsurvdraw4 | -.0404115 .0106734 .9196795 1.022566 dsurvdraw5 | -.0458372 .0091592 .9098577 1.019404 dsurvdraw6 | -.1878871 .0052308 .7566851 1.007905 dsurvdraw7 | -.290524 -.0054474 .5950349 .9903239 ----------------------------------------------------------------- . . * Add $xlist Unweighted is quite balanced. . teffects ipw ($y) (lottery $zlist $xlist), nolog vce(cluster household_id) Treatment-effects estimation Number of obs = 19,393 Estimator : inverse-probability weights Outcome model : weighted mean Treatment model: logit (Std. err. adjusted for 17,348 clusters in household_id) -------------------------------------------------------------------------------- | Robust oop | Coefficient std. err. z P>|z| [95% conf. interval] ---------------+---------------------------------------------------------------- ATE | lottery | (Selected | vs | Not selected) | -38.60386 10.79158 -3.58 0.000 -59.75496 -17.45276 ---------------+---------------------------------------------------------------- POmean | lottery | Not selected | 290.0472 7.711269 37.61 0.000 274.9334 305.161 -------------------------------------------------------------------------------- . tebalance summarize Covariate balance summary Raw Weighted ----------------------------------------- Number of obs = 19,393 19,393.0 Treated obs = 9,674 9,535.6 Control obs = 9,719 9,857.4 ----------------------------------------- ----------------------------------------------------------------- |Standardized differences Variance ratio | Raw Weighted Raw Weighted ----------------+------------------------------------------------ dhhsize2 | .1943111 .006336 1.179851 1.005517 dhhsize3 | .0790861 .0014049 8.606032 1.028515 dlotdraw2 | .0451134 .0052325 1.124067 1.015294 dlotdraw3 | .0277652 .0038393 1.075608 1.011414 dlotdraw4 | -.0252115 -.0075005 .9351396 .9804058 dlotdraw5 | -.0030212 -.0066166 .9917815 .982313 dlotdraw6 | -.0123496 -.0025552 .9817144 .9964734 dlotdraw7 | -.0129114 .0025371 .9800423 1.003574 dlotdraw8 | -.027327 .0085268 .9296931 1.021601 dsurvdraw2 | .2342189 -.0043921 1.813032 .9895836 dsurvdraw3 | .2344951 -.0097945 1.819391 .9770379 dsurvdraw4 | -.040431 .0107333 .920141 1.022562 dsurvdraw5 | -.0450928 .0095733 .9115864 1.0202 dsurvdraw6 | -.1904205 .0060347 .7544714 1.009088 dsurvdraw7 | -.2893345 -.0061828 .5943131 .9889269 dsmoke | .0187514 -.0000515 .9931276 .9996459 hhinc | .0304842 .0021617 .9943622 .9950279 deduc2 | .0104041 -.0005917 1.000053 1 deduc3 | .0064536 .0007747 1.008453 1.001011 deduc4 | -.0178335 .0002722 .9585382 1.000652 demploy2 | .0174877 -2.39e-06 1.050374 .9999967 demploy3 | -.011695 -.0002153 .9697981 .9994367 demploy4 | .0329575 -.0008007 1.034286 .9991902 ----------------------------------------------------------------- . . * Nearest neighbor matching . * Exact match on household size either 1 or > 1 . * Match on mahalanobis distance for the remaining variables . generate dhhbig = dhhsize2 + dhhsize3 . teffects nnmatch ($y $wave) (lottery), ematch(dhhbig) metric(mahalanobis) Treatment-effects estimation Number of obs = 22,679 Estimator : nearest-neighbor matching Matches: requested = 1 Outcome model : matching min = 5 Distance metric: Mahalanobis max = 1018 -------------------------------------------------------------------------------- | AI robust oop | Coefficient std. err. z P>|z| [95% conf. interval] ---------------+---------------------------------------------------------------- ATE | lottery | (Selected | vs | Not selected) | -48.68898 13.83561 -3.52 0.000 -75.80629 -21.57168 -------------------------------------------------------------------------------- . . ********** CLOSE OUTPUT . log close name: log: c:\Users\ccameron\Dropbox\Desktop\TEACHING\190\Methods\treat.txt log type: text closed on: 21 Mar 2023, 14:05:48 ---------------------------------------------------------------------------------