rddensity  R Documentation 
rddensity
implements manipulation testing procedures using the
local polynomial density estimators proposed in Cattaneo, Jansson and Ma (2020),
and implements graphical procedures with valid confidence bands using the results
in Cattaneo, Jansson and Ma (2022, 2023). In addition, the command provides complementary
manipulation testing based on finite sample exact binomial testing following the
esults in Cattaneo, Frandsen and Titiunik (2015) and Cattaneo, Frandsen and
VazquezBare (2017). For an introduction to manipulation testing see McCrary (2008).
A companion Stata
package is described in Cattaneo, Jansson and Ma (2018).
Companion commands: rdbwdensity
for datadriven bandwidth selection, and
rdplotdensity
for density plots.
Related Stata and R packages useful for inference in regression discontinuity (RD) designs are described in the website: https://rdpackages.github.io/.
rddensity( X, c = 0, p = 2, q = 0, fitselect = "", kernel = "", vce = "", massPoints = TRUE, h = c(), bwselect = "", all = FALSE, regularize = TRUE, nLocalMin = NULL, nUniqueMin = NULL, bino = TRUE, binoW = NULL, binoN = NULL, binoWStep = NULL, binoNStep = NULL, binoNW = 10, binoP = 0.5 )
X 
Numeric vector or one dimensional matrix/data frame, the running variable. 
c 
Numeric, specifies the threshold or cutoff value in the support of 
p 
Nonnegative integer, specifies the local polynomial order used to construct
the density estimators. Default is 
q 
Nonnegative integer, specifies the local polynomial order used to construct
the biascorrected density estimators. Default is 
fitselect 
String, specifies the density estimation method.

kernel 
String, specifies the kernel function used to construct the local
polynomial estimators.

vce 
String, specifies the procedure used to compute the variancecovariance matrix estimator.

massPoints 

h 
Numeric, specifies the bandwidth used to construct the density estimators on the two
sides of the cutoff. If not specified, the bandwidth h is computed by the companion command

bwselect 
String, specifies the bandwidth selection procedure to be used.

all 

regularize 

nLocalMin 
Nonnegative integer, specifies the minimum number of observations in each local neighborhood.
This option will be ignored if set to 
nUniqueMin 
Nonnegative integer, specifies the minimum number of unique observations in
each local neighborhood. This option will be ignored if set to 
bino 

binoW 
Numeric, specifies the half length(s) of the initial window. If two values are provided, they will be used for the data below and above the cutoff separately. 
binoN 
Nonnegative integer, specifies the minimum number of observations on each side of the cutoff used for
the binomial test. This option will be ignored if 
binoWStep 
Numeric, specifies the increment in half length(s). 
binoNStep 
Nonnegative integer, specifies the minimum increment in sample size (on each side of the cutoff).
This option will be ignored if 
binoNW 
Nonnegative integer, specifies the total number of windows. Default is 
binoP 
Numeric, specifies the null hypothesis of the binomial test. Default is 
hat 

sd_asy 

sd_jk 

test 

hat_p 
Same as 
sd_asy_p 
Same as 
sd_jk_p 
Same as 
test_p 
Same as 
N 

h 

opt 
Options passed to the function. 
bino 
Binomial test results. 
X_min 

X_max 

Matias D. Cattaneo, Princeton University cattaneo@princeton.edu.
Michael Jansson, University of California Berkeley. mjansson@econ.berkeley.edu.
Xinwei Ma (maintainer), University of California San Diego. x1ma@ucsd.edu.
Cattaneo, M. D., B. Frandsen, and R. Titiunik. 2015. Randomization Inference in the Regression Discontinuity Design: An Application to the Study of Party Advantages in the U.S. Senate. Journal of Causal Inference 3(1): 124. doi: 10.1515/jci20130010
Cattaneo, M. D., M. Jansson, and X. Ma. 2018. Manipulation Testing based on Density Discontinuity. Stata Journal 18(1): 234261. doi: 10.1177/1536867X1801800115
Cattaneo, M. D., M. Jansson, and X. Ma. 2020. Simple Local Polynomial Density Estimators. Journal of the American Statistical Association, 115(531): 14491455. doi: 10.1080/01621459.2019.1635480
Cattaneo, M. D., M. Jansson, and X. Ma. 2022. lpdensity: Local Polynomial Density Estimation and Inference. Journal of Statistical Software, 101(2), 1–25. doi: 10.18637/jss.v101.i02
Cattaneo, M. D., M. Jansson, and X. Ma. 2023. Local Regression Distribution Estimators. Journal of Econometrics, forthcoming. doi: 10.1016/j.jeconom.2021.01.006
Cattaneo, M. D., R. Titiunik and G. VazquezBare. 2017. Comparing Inference Approaches for RD Designs: A Reexamination of the Effect of Head Start on Child Mortality. Journal of Policy Analysis and Management 36(3): 643681. doi: 10.1002/pam.21985
McCrary, J. 2008. Manipulation of the Running Variable in the Regression Discontinuity Design: A Density Test. Journal of Econometrics 142(2): 698714. doi: 10.1016/j.jeconom.2007.05.005
rdbwdensity
, rdplotdensity
### Continuous Density set.seed(42) x < rnorm(2000, mean = 0.5) rdd < rddensity(X = x, vce = "jackknife") summary(rdd) ### Bandwidth selection using rdbwdensity() rddbw < rdbwdensity(X = x, vce = "jackknife") summary(rddbw) ### Plotting using rdplotdensity() # 1. From 2 to 2 with 25 evaluation points at each side plot1 < rdplotdensity(rdd, x, plotRange = c(2, 2), plotN = 25) # 2. Plotting a uniform confidence band set.seed(42) # fix the seed for simulating critical values plot2 < rdplotdensity(rdd, x, plotRange = c(2, 2), plotN = 25, CIuniform = TRUE) ### Density discontinuity at 0 x[x > 0] < x[x > 0] * 2 rdd2 < rddensity(X = x, vce = "jackknife") summary(rdd2) plot3 < rdplotdensity(rdd2, x, plotRange = c(2, 2), plotN = 25)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.