多断点回归设计的分析
Title
rdmc -- Analysis of Regression Discontinuity Designs with Multiple Cutoffs.
Syntax
rdmc depvar runvar [if] [in], cvar(string) [ fuzzy(string) derivvar(string) pooled_opt(string) verbose pvar(string) qvar(string) hvar(string) hrightvar(string) bvar(string) brightvar(string) rhovar(string) covsvar(string) covsdropvar(string)
kernelvar(string) weightsvar(string) bwselectvar(string) scaleparvar(string) scaleregulvar(string) masspointsvar(string) bwcheckvar(string) bwrestrictvar(string) stdvarsvar(string) vcevar(string) level(#) plot graph_opt(string) ]
Description
(2021). It also computes alternative estimation and inference procedures available in the literature.
Companion commands are: rdmcplot for multi-cutoff RD plots, and rdms for multi-score RD estimation and inference.
A detailed introduction to this command is given in Cattaneo, Titiunik and Vazquez-Bare (2020).
Companion R functions are also available here.
This command employs the Stata (and R) package rdrobust for underlying calculations. See Calonico, Cattaneo and Titiunik (2014), Calonico, Cattaneo and Titiunik (2015), and Calonico, Cattaneo, Farrell and Titiunik (2017) for more details.
Related Stata and R packages useful for inference in RD designs are described in the following website:
https://rdpackages.github.io
从精确断点、模糊断点、拐点回归到地理断点回归设计:附经典文献精读的断点回归设计汇总帖
安装:下载阅读原文的“rdmulti-master”包,解压在指定文件夹进行本地安装
net install rdmulti , from(C:\git\rdmulti-master\stata) replace
使用实例:
********************************************************************************
** Load data and generate plot variables (omitting plot)
********************************************************************************
cd F:\rdmc_example\rdmulti-master\stata
use simdata_multic, clear
sum
tab c
rdmcplot y x, c(c) ci(95) genvars nodraw
********************************************************************************
********************************************************************************
** Replicate default plot
********************************************************************************
twoway (scatter rdmcplot_mean_y_1 rdmcplot_mean_x_1, mcolor(navy) msize(small)) ///
(line rdmcplot_hat_y_1 rdmcplot_mean_x_1 if t==1, sort lcolor(navy)) ///
(line rdmcplot_hat_y_1 rdmcplot_mean_x_1 if t==0, sort lcolor(navy)) ///
(scatter rdmcplot_mean_y_2 rdmcplot_mean_x_2, mcolor(maroon) msize(small)) ///
(line rdmcplot_hat_y_2 rdmcplot_mean_x_2 if t==1, sort lcolor(maroon)) ///
(line rdmcplot_hat_y_2 rdmcplot_mean_x_2 if t==0, sort lcolor(maroon)), ///
xline(33, lcolor(navy) lpattern(dash)) ///
xline(66, lcolor(maroon) lpattern(dash)) ///
legend(off)
********************************************************************************
********************************************************************************
** Replicate plot with confidence intervals
********************************************************************************
twoway (scatter rdmcplot_mean_y_1 rdmcplot_mean_x_1, mcolor(navy) msize(small)) ///
(line rdmcplot_hat_y_1 rdmcplot_mean_x_1 if t==1, sort lcolor(navy)) ///
(line rdmcplot_hat_y_1 rdmcplot_mean_x_1 if t==0, sort lcolor(navy)) ///
(scatter rdmcplot_mean_y_2 rdmcplot_mean_x_2, mcolor(maroon) msize(small)) ///
(line rdmcplot_hat_y_2 rdmcplot_mean_x_2 if t==1, sort lcolor(maroon)) ///
(line rdmcplot_hat_y_2 rdmcplot_mean_x_2 if t==0, sort lcolor(maroon)) ///
(rcap rdmcplot_ci_l_1 rdmcplot_ci_r_1 rdmcplot_mean_x_1, sort lcolor(navy)) ///
(rcap rdmcplot_ci_l_2 rdmcplot_ci_r_2 rdmcplot_mean_x_2, sort lcolor(maroon)), ///
xline(33, lcolor(navy) lpattern(dash)) ///
xline(66, lcolor(maroon) lpattern(dash)) ///
legend(off)
net install rdmulti , from(C:\git\rdmulti-master\stata) replace
findit rdmc
help rdmc
//Standard use of rdmc
rdmc yvar xvar, cvar(cvar)
rdmc with plots of estimates and weights
rdmc yvar xvar, cvar(cvar) plot
rdmc showing output from rdrobust and specifying uniform kernel
rdmc yvar xvar, cvar(cvar) verbose pooled_opt(kernel(uniform))
ssc install rdrobust,replace
//ssc install rdplot,replace
*******************************************************************************
** RDMULTI: Analysis of Regression Discontinuity Designs
** with multiple cutoffs or scores
** Illustration file
** Authors: Matias Cattaneo, Rocío Titiunik, Gonzalo Vazquez-Bare
********************************************************************************
** net install rdmulti, from(https://raw.githubusercontent.com/rdpackages/rdmulti/master/stata) replace
********************************************************************************
clear all
set more off
set linesize 90
********************************************************************************
** MULTIPLE NON-CUMULATIVE CUTOFFS: Setup and summary stats
********************************************************************************
use simdata_multic, clear
sum
tab c
********************************************************************************
** RDMC
********************************************************************************
* Basic syntax
rdmc y x, c(c)
* rdrobust pooled options
rdmc y x, c(c) pooled_opt(h(20) p(2)) verbose
* Cutoff-specific bandwidths
gen double h = 11 in 1
replace h = 10 in 2
rdmc y x, c(c) h(h)
* Different bandwidth selectors at each cutoff
gen bwselect = 'msetwo' in 1
replace bwselect = 'certwo' in 2
rdmc y x, c(c) bwselect(bwselect)
* Add plot
rdmc y x, c(c) plot
graph display coefs
graph display weights
* Post estimation testing
rdmc y x, c(c)
matlist e(b)
lincom c1-c2
********************************************************************************
** RDMCPLOT
********************************************************************************
* Basic syntax
rdmcplot y x, c(c)
* Omit bins plot
rdmcplot y x, c(c) nobins
* Plot TE
gen p = 1 in 1/2
rdmcplot y x, c(c) h(h) p(p)
* Plots by hand
rdmcplot y x, c(c) genvars
twoway (scatter rdmcplot_mean_y_1 rdmcplot_mean_x_1, mcolor(navy)) ///
(line rdmcplot_hat_y_1 rdmcplot_mean_x_1 if t==1, sort lcolor(navy)) ///
(line rdmcplot_hat_y_1 rdmcplot_mean_x_1 if t==0, sort lcolor(navy)) ///
(scatter rdmcplot_mean_y_2 rdmcplot_mean_x_2, mcolor(maroon)) ///
(line rdmcplot_hat_y_2 rdmcplot_mean_x_2 if t==1, sort lcolor(maroon)) ///
(line rdmcplot_hat_y_2 rdmcplot_mean_x_2 if t==0, sort lcolor(maroon)), ///
xline(33, lcolor(navy) lpattern(dash)) ///
xline(66, lcolor(maroon) lpattern(dash)) ///
legend(off)
********************************************************************************
** MULTIPLE CUMULATIVE CUTOFFS: Setup and summary stats
********************************************************************************
use simdata_cumul, clear
sum
tab c
********************************************************************************
** RDMS
********************************************************************************
* Basic syntax
rdms y x, c(c)
* Cutoff-specific bandwidths
gen double h = 11 in 1
replace h = 8 in 2
gen kernel = 'uniform' in 1
replace kernel = 'triangular' in 2
rdms y x, c(c) h(h) kernel(kernel)
* Restricting the range
gen double range_l = 0 in 1
gen double range_r = 65.5 in 1
replace range_l = 33.5 in 2
replace range_r = 100 in 2
rdms y x, c(c) range(range_l range_r)
* Pooled estimate using rdmc
gen double cutoff = c[1]*(x<=49.5) + c[2]*(x>49.5)
rdmc y x, c(cutoff)
* Plot using rdmcplot
gen binsopt = 'mcolor(navy)' in 1/2
gen xlineopt = 'lcolor(navy) lpattern(dash)' in 1/2
rdmcplot y x, c(cutoff) binsoptvar(binsopt) xlineopt(xlineopt) nopoly
********************************************************************************
** BIVARIATE SCORE: Setup and summary stats
********************************************************************************
use simdata_multis, clear
sum
list c1 c2 in 1/3
gen xaux = 50 in 1/50
gen yaux = _n in 1/50
twoway (scatter x2 x1 if t==0, msize(small) mfcolor(white) msymbol(X)) ///
(scatter x2 x1 if t==1, msize(small) mfcolor(white) msymbol(T)) ///
(function y = 50, range(0 50) lcolor(black) lwidth(medthick)) ///
(line yaux xaux, lcolor(black) lwidth(medthick)) ///
(scatteri 50 25, msize(large) mcolor(black)) ///
(scatteri 50 50, msize(large) mcolor(black)) ///
(scatteri 25 50, msize(large) mcolor(black)), ///
text(25 25 'Treated', size(vlarge)) ///
text(60 60 'Control', size(vlarge)) ///
legend(off)
********************************************************************************
** RDMS
********************************************************************************
* Basic syntax
rdms y x1 x2 t, c(c1 c2)
* Cutoff specific bandwidths
gen double h = 15 in 1
replace h = 13 in 2
replace h = 17 in 3
rdms y x1 x2 t, c(c1 c2) h(h)
* Pooled effect
gen double aux1 = abs(50 - x1)
gen double aux2 = abs(50 - x2)
egen xnorm = rowmin(aux1 aux2)
replace xnorm = xnorm*(2*t-1)
rdms y x1 x2 t, c(c1 c2) xnorm(xnorm)
* Plots by hand:
* BIVARIATE SCORE: Setup and summary stats:
赞 (0)