This convenience function computes weights using the Imbens-Kalyanaraman bandwidth procedure. The code does exactly what the MATLAB code available on the author's website does.
Usage
IK_bandwidth(Y, X, threshold, kernel = c("triangular", "uniform"))
References
Imbens, G., and Kalyanaraman, K. (2012). Optimal Bandwidth Choice for the Regression Discontinuity Estimator. The Review of Economic Studies, 79(3).
Examples
# \donttest{
n = 1000; threshold = 0
X = runif(n, -1, 1)
W = as.numeric(X >= threshold)
Y = (1 + 2*W)*(1 + X^2) + 1 / (1 + exp(X)) + rnorm(n, sd = .5)
out = IK_bandwidth(Y, X, threshold)
# }