Skip to contents

The running variable is binned, the bin heights become a density, and a local linear regression with triangular kernel is run on each side and evaluated at the cutoff. The statistic is \(\theta = \log \hat f_+(c) - \log \hat f_-(c)\) with \(se(\theta) = \sqrt{(1/(nh))(24/5)(1/\hat f_+ + 1/\hat f_-)}\) and \(z = \theta/se(\theta)\) referred to the normal. The 24/5 is the triangular-kernel constant for a boundary local linear estimator and is not interchangeable with the interior constant. Defaults follow McCrary's own code: bin width \(2 s n^{-1/2}\) and a per-side bandwidth \(h = 3.348 (mse_4 \cdot range / \sum f''^2)^{1/5}\) averaged over the two sides, with the binned densities zero-padded out one bandwidth so the boundary regressions see the empty tail. A rejection says the density jumps; failing to reject is not evidence that assignment is as good as random.

Usage

Rddmanip(x, cutoff = 0, bw = NULL, binsize = NULL)

Arguments

x

Running variable.

cutoff

Threshold, strictly inside the range of x.

bw

Bandwidth; McCrary's automatic rule if NULL.

binsize

Bin width; 2 s n^(-1/2) if NULL.

Value

List with estimate (theta), se, statistic, p_value, fhat_left, fhat_right, bw, binsize, n, method.

References

McCrary (2008), Journal of Econometrics 142:698-714. The coded form follows McCrary's own implementation as distributed in Dimmery's rdd package, R/DCdensity.R, which gives the binning, the 3.348 pilot bandwidth rule, the zero padding, the triangular weights and sethetahat verbatim.

Examples

set.seed(1)
x <- c(runif(100, -1, 0), runif(120, 0, 1))
Rddmanip(x)
#> $estimate
#> [1] -0.09822019
#> 
#> $se
#> [1] 0.7871212
#> 
#> $statistic
#> [1] -0.1247841
#> 
#> $p_value
#> [1] 0.9006945
#> 
#> $fhat_left
#> [1] 0.2274497
#> 
#> $fhat_right
#> [1] 0.2061717
#> 
#> $bw
#> [1] 0.3256354
#> 
#> $binsize
#> [1] 0.07664247
#> 
#> $n
#> [1] 220
#> 
#> $method
#> [1] "McCrary density discontinuity test"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"