rddapp (version 1.1.0)

dc_test: McCrary Sorting Test

Description

dc_test implements the McCrary (2008) sorting test. 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

Numerical vector of the running variable.

cutpoint

The cutpoint (defaults to 0).

bin

The binwidth (defaults to 2*sd(runvar)*length(runvar)^(-.5)).

bw

The bandwidth to use (by default uses bandwidth selection calculation from McCrary (2008)).

verbose

Logical flag specifying whether to print diagnostic information to the terminal (defaults to TRUE).

plot

Logical flag indicating whether to plot the histogram and density estimations (defaults to TRUE). The user may wrap this function in additional graphical options to modify the plot.

ext.out

Logical flag indicating whether to return extended output. When FALSE (the default) DCdensity will return only the p-value of the test. When TRUE, DCdensity will return the additional information documented below.

htest

Logical flag indicating whether to return an "htest" object compatible with base R's hypothesis test output.

level

Numerical value between 0 and 1. Confidence level for confidence intervals.

digits

Number of digits to display.

timeout

Numerical value specifying the maximum number of seconds (defaults to 30 seconds) expressions in the function are allowed to run. Specify Inf to run all expressions to completion.

...

Additional arguments affecting the plot.

Value

If ext.out is FALSE, only the p value will be returned. Additional output is enabled when ext.out is TRUE. In this case, a list will be returned with the following elements:

theta

The estimated log difference in heights at the cutpoint.

se

The standard error of theta.

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 cellmp (the midpoints of each cell) and cellval (the normalized height of each cell).

References

McCrary, J. (2008). Manipulation of the running variable in the regression discontinuity design: A density test. Journal of Econometrics, 142(2), 698-714. http://dx.doi.org/10.1016/j.jeconom.2007.05.005.

Examples

Run this code
# NOT RUN {
# 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)
# }

Run the code above in your browser using DataCamp Workspace