Description Usage Arguments Value Author(s) References See Also Examples
rddensity
implements manipulation testing procedures using the
local polynomial density estimators proposed in Cattaneo, Jansson and Ma (2020a),
and implements graphical procedures with valid confidence bands using the results
in Cattaneo, Jansson and Ma (2020b,c). 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/.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 
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 number of observations (closest to 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 increment in sample size.
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.
Cattaneo, M. D., M. Jansson, and X. Ma. 2018. Manipulation Testing based on Density Discontinuity. Stata Journal 18(1): 234261.
Cattaneo, M. D., M. Jansson, and X. Ma. 2020a. Simple Local Polynomial Density Estimators. Journal of the American Statistical Association, 115(531): 14491455.
Cattaneo, M. D., M. Jansson, and X. Ma. 2020b. Local Regression Distribution Estimators. Working paper.
Cattaneo, M. D., M. Jansson, and X. Ma. 2020c. lpdensity: Local Polynomial Density Estimation and Inference. Working paper.
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.
McCrary, J. 2008. Manipulation of the Running Variable in the Regression Discontinuity Design: A Density Test. Journal of Econometrics 142(2): 698714.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  ### 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.