dc_test {rddapp} | R Documentation |
McCrary Sorting Test
Description
dc_test
implements the McCrary (2008) sorting test to identify violations of assignment rules.
It is based on the DCdensity
function in the "rdd" package.
Usage
dc_test(
runvar,
cutpoint,
bin = NULL,
bw = NULL,
verbose = TRUE,
plot = TRUE,
ext.out = FALSE,
htest = FALSE,
level = 0.95,
digits = max(3, getOption("digits") - 3),
timeout = 30
)
Arguments
runvar |
A numeric vector containing the running variable. |
cutpoint |
A numeric value containing the cutpoint at which assignment to the treatment is determined. The default is 0. |
bin |
A numeric value containing the binwidth. The default is |
bw |
A numeric value containing bandwidth to use. If no bandwidth is supplied, the default uses bandwidth selection calculation from McCrary (2008). |
verbose |
A logical value indicating whether to print diagnostic information to
the terminal. The default is |
plot |
A logical value indicating whether to plot the histogram and density estimations
The default is |
ext.out |
A logical value indicating whether to return extended output.
The default is |
htest |
A logical value indicating whether to return an |
level |
A numerical value between 0 and 1 specifying the confidence level for confidence intervals. The default is 0.95. |
digits |
A non-negative integer specifying the number of digits to display in all output.
The default is |
timeout |
A non-negative numerical value specifying the maximum number of seconds that
expressions in the function are allowed to run. The default is 30. Specify |
Value
If ext.out
is FALSE
, dc_test
returns a numeric value specifying the p-value of the McCrary (2008) sorting test.
Additional output is enabled when ext.out
is TRUE
.
In this case, dc_test
returns a list with the following elements:
theta |
The estimated log difference in heights of the density curve at the cutpoint. |
se |
The standard error of |
z |
The z statistic of the test. |
p |
The p-value of the test. A p-value below the significance threshold indicates that the user can reject the null hypothesis of no sorting. |
binsize |
The calculated size of bins for the test. |
bw |
The calculated bandwidth for the test. |
cutpoint |
The cutpoint used. |
data |
A dataframe for the binning of the histogram. Columns are |
References
McCrary, J. (2008). Manipulation of the running variable in the regression discontinuity design: A density test. Journal of Econometrics, 142(2), 698-714. doi:10.1016/j.jeconom.2007.05.005.
Drew Dimmery (2016). rdd: Regression Discontinuity Estimation. R package version 0.57. https://CRAN.R-project.org/package=rdd
Examples
set.seed(12345)
# No discontinuity
x <- runif(1000, -1, 1)
dc_test(x, 0)
# Discontinuity
x <- runif(1000, -1, 1)
x <- x + 2 * (runif(1000, -1, 1) > 0 & x < 0)
dc_test(x, 0)