use 'E:statadatardrobust_rdsenate.dta' . ed . desc Contains data from E:statadatardrobust_rdsenate.dta Observations: 1,390 Variables: 2 28 Nov 2012 11:45 ------------------------------------------------------------------------------------------------------------------------------------- Variable Storage Display Value name type format label Variable label ------------------------------------------------------------------------------------------------------------------------------------- margin float %9.0g Democratic margin of victory at t (previous election for same seat) vote float %9.0g Democratic vote share at t+2 ------------------------------------------------------------------------------------------------------------------------------------- Sorted by: . histogram margin , lcolor ( brown ) fcolor ( gs16 ) title ( 'Senate_selection' ) xtitle ( 'margin' ) (bin=31, start=-100, width=6.4516129) .
options Description -------------------------------------------------------------------------- Options alpha(real) specifies critical value for calculation of optimal bandwidth threshold(real) specifies cutoff value for the test qobs(real) specifies # of observations closest to cutoff ------------------------------------------------------------------------
clear set more off capture log close //cd'...' //Change to working directory log using 'rdcont_example.smcl', replace ******************************************************************************** //Bugni & Canay (2019) RDD Continuity test on Lee(2008) ******************************************************************************** use table_two_final.dta, clear //Loading data capture program drop rdcont //Installing rdcont program //Approximate Sign-Test | Bugni & Canay rdcont difdemshare if use==1 return list log off
使用上述案例数据进行操作的代码为:
rdcont margin , threshold ( 0 )
结果为
rdcont margin , threshold ( 0 ) RDD non-randomized approximate sign test Running variable: margin Cutoff c = 0 | Left of c Right of c Number of obs = 1390 -------------------+---------------------- q = 67 Number of obs | 640 750 Eff. number of obs | 30 37 Eff. neighborhood | -1.347 1.329 -------------------+---------------------- p-value | 0.464
rddensity var [if] [in] [, c(#) p(#) q(#) kernel(kernelfn) fitselect(fitmethod) hl(#) hr(#) hscale(#) bwselect(bwmethod) vce(vcemethod) all ]
操作1、使用默认选项进行操作Manipulation test using default options:
rddensity margin use 'E:statadatardrobust_rdsenate.dta' . rddensity margin Computing data-driven bandwidth selectors. RD Manipulation Test using local polynomial density estimation. Cutoff c = 0.000 | Left of c Right of c Number of obs = 1390 ----------------------+---------------------- Model = unrestricted Number of obs | 640 750 BW method = comb Eff. Number of obs | 408 460 Kernel = triangular Order loc. poly. (p) | 2 2 VCE method = jackknife Order BC (q) | 3 3 Bandwidths (hl,hr) | estimated estimated Bandwidth values | 19.841 27.119 Running variable: margin. --------------------------------------------- Method | T P>|T| ----------------------+---------------------- Robust Bias-Corrected | -0.8753 0.3814 ---------------------------------------------
操作2、Manipulation test using all three method available:
. rddensity margin, all
结果为
. rddensity margin, all Computing data-driven bandwidth selectors. RD Manipulation Test using local polynomial density estimation. Cutoff c = 0.000 | Left of c Right of c Number of obs = 1390 ----------------------+---------------------- Model = unrestricted Number of obs | 640 750 BW method = comb Eff. Number of obs | 408 460 Kernel = triangular Order loc. poly. (p) | 2 2 VCE method = jackknife Order BC (q) | 3 3 Bandwidths (hl,hr) | estimated estimated Bandwidth values | 19.841 27.119 Bandwidth scales | 0.500 0.500 Running variable: margin. --------------------------------------------- Method | T P>|T| ----------------------+---------------------- Conventional | -1.6506 0.0988 Undersmoothed | -0.8944 0.3711 Robust Bias-Corrected | -0.8753 0.3814 ---------------------------------------------