Skip to contents

Native implementation of the Imbens & Kalyanaraman (2012) three-step plug-in rule: pilot density and conditional variance at the cutoff, one-sided curvature estimates, and the regularized MSE-optimal bandwidth with the kernel constant.

Usage

morie_rdd_bandwidth_ik(x, y, cutoff = 0, kernel = "triangular")

Arguments

x

Numeric vector of running-variable values (used by bandwidth selectors + density tests that don't take a data.frame).

y

Numeric vector of outcome values aligned with x.

cutoff

Numeric scalar; the threshold on running. Default 0 (the canonical normalisation).

kernel

One of "triangular" (default), "epanechnikov", "uniform", or "gaussian".

Value

A named list with elements bandwidth, method, details.

Examples

set.seed(40)
x <- runif(1000, -1, 1)
y <- 0.5 + 0.8 * x - 0.4 * x^2 + 1.2 * (x >= 0) + rnorm(1000, 0, 0.4)
bw <- morie_rdd_bandwidth_ik(x, y)
bw$bandwidth
#> [1] 1.032664