--------------------------------------------------------------------------------- name: log: c:\Users\ccameron\Dropbox\Desktop\TEACHING\190\Methods\rdd.txt log type: text opened on: 21 Mar 2023, 14:08:43 . . ********** OVERVIEW OF rdd.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 . * AED_INCUMBENCY.DTA . * in your directory . . * The dataset is used in chapter 13.7 of . * A. Colin Cameron Analysis of Economics Data: An Introduction to Econometics . * https://cameron.econ.ucdavis.edu/ . * It is studied in more detail in A. Colin Cameron and Pravin K. Trivedi (2022) . * Microeconometrics using Stata, Voulme 2, chapter 25.7 . . * Original source is File rdsenate.dta from . * Sebastian Calonico, Matias Cattaneo, Max Farrell, and RocĂ­o Titiunik (2017), . * "Rdrobust: Software for Regression-discontinuity Designs," . * The Stata Journal, 17(2), pages 372-404. . . ********** SETUP ********** . . clear all . set scheme s1mono /* Graphics scheme */ . . ************ REGRESSION DISCONTINUITY DESIGN . . use AED_INCUMBENCY.DTA, clear (Data for A. Colin Cameron (2022), ANALYSIS OF ECONOMIC DATA, Amazon) . describe Contains data from AED_INCUMBENCY.DTA Observations: 1,390 Data for A. Colin Cameron (2022), ANALYSIS OF ECONOMIC DATA, Amazon Variables: 9 22 Jan 2022 15:04 --------------------------------------------------------------------------------- Variable Storage Display Value name type format label Variable label --------------------------------------------------------------------------------- state float %9.0g State ID year float %10.0g Election Year vote float %9.0g Democratic vote share in next election margin float %9.0g Democratic margin of victory class float %9.0g Senate class termshouse int %54.0g Cummulative number of terms served in U.S. House by congress of record termssenate int %53.0g Cummulative number of terms served in U.S. Senate by congress of record population long %10.0g State population win float %9.0g = 1 if margin > 0 --------------------------------------------------------------------------------- Sorted by: state year . summarize Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- state | 1,390 40.01367 21.99304 1 82 year | 1,390 1964.63 28.05466 1914 2010 vote | 1,297 52.66627 18.12219 0 100 margin | 1,390 7.171159 34.32488 -100 100 class | 1,390 2.023022 .8231983 1 3 -------------+--------------------------------------------------------- termshouse | 1,108 1.436823 2.357133 0 16 termssenate | 1,108 4.555957 3.720294 1 20 population | 1,390 3827919 4436950 78000 3.73e+07 win | 1,390 .5395683 .4986113 0 1 . summarize margin vote win Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- margin | 1,390 7.171159 34.32488 -100 100 vote | 1,297 52.66627 18.12219 0 100 win | 1,390 .5395683 .4986113 0 1 . . * Basic look at data - outcome increases with the running variable . twoway (scatter vote margin, msize(tiny)) (qfit vote margin, lcol(black)), /// > title("Outcome increases with running variable") /// > ytitle("Vote at subsequent election") scale(1.2) /// > xtitle("Margin of victory at initial election") legend(off) . graph export rddfig1.wmf, replace file c:\Users\ccameron\Dropbox\Desktop\TEACHING\190\Methods\rddfig1.wmf saved as Windows Metafile format . . * Sharp RD: scatterplot of the data with quadratic fit . twoway (scatter vote margin, msize(tiny) xline(0)) /// > (qfit vote margin if margin<0, lcol(black)) /// > (qfit vote margin if margin>0, lcol(black)), scale(1.2) /// > title("RDD Treatment Effect") ytitle("Vote at subsequent election") /// > xtitle("Margin of victory at initial election") legend(off) . graph export rddfig2.wmf, replace file c:\Users\ccameron\Dropbox\Desktop\TEACHING\190\Methods\rddfig2.wmf saved as Windows Metafile format . . capture drop winmarg marginsq winmargsq . . * Regression analysis - quadratic on each side . generate winmarg = win*margin . generate marginsq = margin^2 . generate winmargsq = win*marginsq . regress vote win margin marginsq winmarg winmargsq, vce(robust) noheader ------------------------------------------------------------------------------ | Robust vote | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- win | 4.934817 1.128685 4.37 0.000 2.72056 7.149074 margin | .4206294 .07891 5.33 0.000 .2658234 .5754353 marginsq | .0030298 .0012332 2.46 0.014 .0006105 .0054492 winmarg | -.094709 .0973555 -0.97 0.331 -.2857014 .0962833 winmargsq | -.0024027 .0013705 -1.75 0.080 -.0050913 .000286 _cons | 46.73955 .842152 55.50 0.000 45.08742 48.39169 ------------------------------------------------------------------------------ . . * Regression analysis - various models . * Table 13.12 - no treatment variable . regress vote margin, vce(robust) Linear regression Number of obs = 1,297 F(1, 1295) = 976.19 Prob > F = 0.0000 R-squared = 0.5693 Root MSE = 11.898 ------------------------------------------------------------------------------ | Robust vote | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- margin | .3966992 .0126968 31.24 0.000 .3717907 .4216077 _cons | 49.53683 .3411136 145.22 0.000 48.86763 50.20602 ------------------------------------------------------------------------------ . estimates store notreat . * Table 13.12 - linear treatment variable . regress vote win margin, vce(robust) Linear regression Number of obs = 1,297 F(2, 1294) = 591.42 Prob > F = 0.0000 R-squared = 0.5781 Root MSE = 11.781 ------------------------------------------------------------------------------ | Robust vote | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- win | 4.78461 .859808 5.56 0.000 3.09784 6.471381 margin | .3480624 .0170433 20.42 0.000 .3146269 .3814979 _cons | 47.33084 .5262176 89.95 0.000 46.29851 48.36318 ------------------------------------------------------------------------------ . estimates store linear . * Table 13.12 - quadratic in treatment variable . regress vote win margin marginsq winmarg winmargsq, vce(robust) Linear regression Number of obs = 1,297 F(5, 1291) = 262.74 Prob > F = 0.0000 R-squared = 0.5912 Root MSE = 11.609 ------------------------------------------------------------------------------ | Robust vote | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- win | 4.934817 1.128685 4.37 0.000 2.72056 7.149074 margin | .4206294 .07891 5.33 0.000 .2658234 .5754353 marginsq | .0030298 .0012332 2.46 0.014 .0006105 .0054492 winmarg | -.094709 .0973555 -0.97 0.331 -.2857014 .0962833 winmargsq | -.0024027 .0013705 -1.75 0.080 -.0050913 .000286 _cons | 46.73955 .842152 55.50 0.000 45.08742 48.39169 ------------------------------------------------------------------------------ . estimates store sepquad . * Table 13.12 - local is previous model but considers only margin < 25 . regress vote win margin marginsq winmarg winmargsq if abs(margin) < 25, vce(rob > ust) Linear regression Number of obs = 845 F(5, 839) = 66.61 Prob > F = 0.0000 R-squared = 0.2902 Root MSE = 9.8318 ------------------------------------------------------------------------------ | Robust vote | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- win | 6.750209 1.711842 3.94 0.000 3.390213 10.11021 margin | .1691663 .2764715 0.61 0.541 -.3734907 .7118232 marginsq | -.0028464 .0114293 -0.25 0.803 -.0252797 .019587 winmarg | .2826829 .354865 0.80 0.426 -.4138446 .9792103 winmargsq | -.007025 .0145293 -0.48 0.629 -.0355429 .021493 _cons | 45.29933 1.334435 33.95 0.000 42.68011 47.91855 ------------------------------------------------------------------------------ . estimates store local . * Previous model with cluster-robust standard errors . regress vote win margin marginsq winmarg winmargsq if abs(margin) < 25, vce(clu > ster state) Linear regression Number of obs = 845 F(5, 49) = 50.90 Prob > F = 0.0000 R-squared = 0.2902 Root MSE = 9.8318 (Std. err. adjusted for 50 clusters in state) ------------------------------------------------------------------------------ | Robust vote | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- win | 6.750209 1.779476 3.79 0.000 3.174218 10.3262 margin | .1691663 .2721161 0.62 0.537 -.3776715 .716004 marginsq | -.0028464 .0115833 -0.25 0.807 -.026124 .0204312 winmarg | .2826829 .3568624 0.79 0.432 -.434459 .9998248 winmargsq | -.007025 .0151406 -0.46 0.645 -.0374512 .0234013 _cons | 45.29933 1.435766 31.55 0.000 42.41405 48.18461 ------------------------------------------------------------------------------ . estimates store localclu . * All including cluster-robust se estimates . estimates table notreat linear sepquad local localclu, /// > keep(win margin marginsq winmarg winmargsq _cons) b(%9.4f) se stats(N r2) -------------------------------------------------------------------------- Variable | notreat linear sepquad local localclu -------------+------------------------------------------------------------ win | 4.7846 4.9348 6.7502 6.7502 | 0.8598 1.1287 1.7118 1.7795 margin | 0.3967 0.3481 0.4206 0.1692 0.1692 | 0.0127 0.0170 0.0789 0.2765 0.2721 marginsq | 0.0030 -0.0028 -0.0028 | 0.0012 0.0114 0.0116 winmarg | -0.0947 0.2827 0.2827 | 0.0974 0.3549 0.3569 winmargsq | -0.0024 -0.0070 -0.0070 | 0.0014 0.0145 0.0151 _cons | 49.5368 47.3308 46.7396 45.2993 45.2993 | 0.3411 0.5262 0.8422 1.3344 1.4358 -------------+------------------------------------------------------------ N | 1297 1297 1297 845 845 r2 | 0.5693 0.5781 0.5912 0.2902 0.2902 -------------------------------------------------------------------------- Legend: b/se . * Table 13.12 . estimates table notreat linear sepquad local localclu, /// > keep(win margin marginsq winmarg winmargsq _cons) b(%9.4f) se stats(N r2) > -------------------------------------------------------------------------- Variable | notreat linear sepquad local localclu -------------+------------------------------------------------------------ win | 4.7846 4.9348 6.7502 6.7502 | 0.8598 1.1287 1.7118 1.7795 margin | 0.3967 0.3481 0.4206 0.1692 0.1692 | 0.0127 0.0170 0.0789 0.2765 0.2721 marginsq | 0.0030 -0.0028 -0.0028 | 0.0012 0.0114 0.0116 winmarg | -0.0947 0.2827 0.2827 | 0.0974 0.3549 0.3569 winmargsq | -0.0024 -0.0070 -0.0070 | 0.0014 0.0145 0.0151 _cons | 49.5368 47.3308 46.7396 45.2993 45.2993 | 0.3411 0.5262 0.8422 1.3344 1.4358 -------------+------------------------------------------------------------ N | 1297 1297 1297 845 845 r2 | 0.5693 0.5781 0.5912 0.2902 0.2902 -------------------------------------------------------------------------- Legend: b/se . . * For better analysis using locval polynomials see . * Microeconometrics using Stata, Voulme 2, chapter 25.7 . . * Sharp RD: check on the running variable . kdensity margin, kernel(rectangle) bw(3) xline(0) connect(J) /// > xtitle("Margin of victory at initial election") /// > title("RDD Check Running Variable") saving(graph2.gph, replace) file graph2.gph saved . graph export rddfig3.wmf, replace file c:\Users\ccameron\Dropbox\Desktop\TEACHING\190\Methods\rddfig3.wmf saved as Windows Metafile format . . ********** CLOSE OUTPUT . log close name: log: c:\Users\ccameron\Dropbox\Desktop\TEACHING\190\Methods\rdd.txt log type: text closed on: 21 Mar 2023, 14:08:48 ---------------------------------------------------------------------------------